Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ambushsabre
Sep 1, 2009

It's...it's not shutting down!

Sagacity posted:

Well, yes, but that's a target audience I don't want to ignore :)

An alternative would be to build something using Unity, but then the online crowd probably won't want to play it, since just about nobody has the Unity web player installed (or do they?)

Just offer a web version with unity player if people have it installed / want to download it, and then offer a download version to those who prefer that. Unity is your best bet when it comes to cross-platform (it can support literally everything except linux), except actually getting the licenses to publish on those platforms is another matter (lots and lots of :10bux:)

edit: looks like it does support ps3 after-all. Just linux then!

ambushsabre fucked around with this message at 19:38 on Dec 13, 2010

Adbot
ADBOT LOVES YOU

Senso
Nov 4, 2005

Always working

ambushsabre posted:

Unity is your best bet when it comes to cross-platform (it can support literally everything except PlayStation)

And Linux. :rolleyes:

ambushsabre
Sep 1, 2009

It's...it's not shutting down!

Senso posted:

And Linux. :rolleyes:

Completely correct, I'm not sure how I forgot that considering I use linux every day!

Surface
May 5, 2007
<3 boomstick

ambushsabre posted:

Completely correct, I'm not sure how I forgot that considering I use linux every day!

Maybe it didn't even occur to you that games should work on linux?

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

roomforthetuna posted:

Which is why I went on to say that your plan to use HTML5 seemingly ignores iPhones anyway so is a silly idea.
Excellent point!

roomforthetuna posted:

(Hasn't someone made a Flash compiler that makes an iPhone app out of a Flash thing? Won't be in a webpage but will be supporting iPhone, if you can do it that way.)
Hmm, that packager looks like it might be convenient.

ambushsabre posted:

Good Unity advice
I agree I could do a web/download combination, but I think that the barrier of entry would be too high for just a relatively small throwaway promotional game, so to speak.

Hmm, I'll probably go for Flash then anyway. Just for shits and giggles, I might even give haXe a go. It can't be worse than ActionScript, am I right? :tipshat:

Senso
Nov 4, 2005

Always working

Surface posted:

Maybe it didn't even occur to you that games should work on linux?

Well, Flash works on Linux. As does HTML5. As do most Java games. There, you've got 95% of browser games covered running on Linux.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Senso posted:

Well, Flash works on Linux. As does HTML5. As do most Java games. There, you've got 95% of browser games covered running on Linux.
Would the iPhone browser support Java games? If so, that would probably make it the best option for Sagacity, apart from the whole "it pretty much sucks to work with compared to Flash" thing, but I'm sure that would have been true of HTML5 as well.

haveblue
Aug 15, 2005



Toilet Rascal

roomforthetuna posted:

Would the iPhone browser support Java games? If so, that would probably make it the best option for Sagacity, apart from the whole "it pretty much sucks to work with compared to Flash" thing, but I'm sure that would have been true of HTML5 as well.

No Java or plugins of any kind on the phone. It's JS/HTML5 or nothing.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
I just spent some time looking at haXe and I must say that, apart from the reasonably lame name, it looks quite promising. Through third-party libraries it supports modern engineering practices like TDD, dependency injection and a nice pub/sub eventing model.

I'd use it to compile to Flash. For the iPhone I can then either look at using Adobe's Air packager and, failing that, I can compile the haXe to C++ and have at least the whole game logic already up and running natively.

Well, in theory anyway.

ambushsabre
Sep 1, 2009

It's...it's not shutting down!

Sagacity posted:

I just spent some time looking at haXe and I must say that, apart from the reasonably lame name, it looks quite promising. Through third-party libraries it supports modern engineering practices like TDD, dependency injection and a nice pub/sub eventing model.

I'd use it to compile to Flash. For the iPhone I can then either look at using Adobe's Air packager and, failing that, I can compile the haXe to C++ and have at least the whole game logic already up and running natively.

Well, in theory anyway.

This is assuming you're not using any libraries that help with Flash game creation then? At least when I've tried it, trying to write games in just AS3 (or HaXe) is a huge pain in the rear end and not worth it at all. Is publishing to iPhone really that important to you? I hate to sound like a broken record, but why do that when you can using Flixel or Flashpunk with AS3 and actually enjoy the programming you're doing, as well as being cross platform. If you really want you can compile to air and try to get it running on the Android. It seems to me that you're trying way to hard to include literally every platform instead of actually making the game. I know choosing a tool is an important step, but if it's just a little advertising game like the mentioned above then making it in flash and only having it be available on PC/Mac/Linux sounds like the way to go. If you really want iPhone then get the SDK and write it with the graphics libraries they provide. I wouldn't rely on literally compiling something twice to get it to run on a platform with very specific requirements like the iPhone (from what I hear the adobe packager for iPhone doesn't work to well with games, especially if you're going from HaXe to Flash to iPhone). It just seems like a convoluted mess to me. However, you are not me and feel free to ignore everything I just said, considering I don't really know the whole story (maybe you were hired to make the game on the iPhone?).

Surface
May 5, 2007
<3 boomstick

Senso posted:

Well, Flash works on Linux. As does HTML5. As do most Java games. There, you've got 95% of browser games covered running on Linux.

Heh, well I guess it didn't occur to me that browser games should be considered games. Kidding.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

ambushsabre posted:

This is assuming you're not using any libraries that help with Flash game creation then? *snip* It seems to me that you're trying way to hard to include literally every platform instead of actually making the game.
Yes, I'm sorry, I should have been a bit more detailed. Although iPhone is not a requirement now, it's going to be very reasonable to assume iPhone will be a target. Also, if this game performs to expectation, I think more games will be in the pipeline.

The reason I'm not skewing towards the existing engines is, well, I did take a look at Flixel and Flashpunk and to be honest I thought they looked fairly hacked together. That doesn't mean they're not good for what they do, and for instance PushButton already looked a bit better, but I also just want to spend a bit of time getting the game entity system right (sorry, that sounds a bit pompous :() as a personal exercise. Normally I wouldn't advocate any of this, since there are plenty of "hay guys I am writing a MMORPG engine"-type posts here, but I'm fairly confident that I can pull that off. I did a few games in the early '00s and I'm sure I'll have fun building those parts again.

Anyway, the reason I'm so adamant about the cross-platform stuff is that I don't want to implement large parts of the game twice. Though I may have to build some of the low-level sound and graphics code twice, and some of the interaction, I would prefer to build the actual game logic once.

Also, thanks for the advice and I actually *do* appreciate your broken recordness :) But hopefully now I made my position a bit clearer so you understand a bit better why I'm making certain choices.

Jewel
May 2, 2009

I have no idea why I can't do this, I'm just having a mental blank today I think.

I'm making something 2D topdown using XNA and I have a list full of entities that slowly move towards the player. If we act as if the entities are circles, how would I make them "slide" against eachother/walls, like how in an fps when you move against a wall you slide along it instead of just stopping abruptly?

Jewel fucked around with this message at 10:30 on Dec 17, 2010

Vino
Aug 11, 2010
A circle collision check is really just a distance check, so you're looking at the distance between two circles (add their radii up) or the point-line distance equation. If you get a collision of two circles, you can move them apart from each other pretty easy, if it's a collision of a circle and a wall/line, you should change the velocity of the circle entity to be parallel to the wall, or perhaps move it away from the wall in a direction perpendicular to the wall.

I guess does any of that make sense?

Jewel
May 2, 2009

Vino posted:

A circle collision check is really just a distance check, so you're looking at the distance between two circles (add their radii up) or the point-line distance equation. If you get a collision of two circles, you can move them apart from each other pretty easy, if it's a collision of a circle and a wall/line, you should change the velocity of the circle entity to be parallel to the wall, or perhaps move it away from the wall in a direction perpendicular to the wall.

I guess does any of that make sense?

Hm, it does make sense but it's hard to visualise how to implement it right. If I collide with a wall I have to push myself perpendicular to it until I am no longer touching it? Flat walls kinda make sense, so with a circle do I just do the same yet move in the opposite direction from you and it?

Vino
Aug 11, 2010

Tw1tchy posted:

Hm, it does make sense but it's hard to visualise how to implement it right. If I collide with a wall I have to push myself perpendicular to it until I am no longer touching it? Flat walls kinda make sense, so with a circle do I just do the same yet move in the opposite direction from you and it?

I think what I would do is, you do a trace to see if the movement that you're about to do collides with the wall. If it does, then you stop the movement mid-way and apply another movement that goes parallel to the wall. That way you get the entire length of the movement, but part of it went before it hit the wall and the other part went parallel afterward. You can do this over and over for every wall, in case there's another nearby wall that the object would also hit, until the object is done moving for that frame.

Alternatively, you can do a push-out method. If your circle is x radius and it's x-y distance from the wall then you can push it perpendicular y units and it'll be in the right spot.

I really wish I could draw a diagram.

Jewel
May 2, 2009

Vino posted:

I think what I would do is, you do a trace to see if the movement that you're about to do collides with the wall. If it does, then you stop the movement mid-way and apply another movement that goes parallel to the wall. That way you get the entire length of the movement, but part of it went before it hit the wall and the other part went parallel afterward. You can do this over and over for every wall, in case there's another nearby wall that the object would also hit, until the object is done moving for that frame.

Alternatively, you can do a push-out method. If your circle is x radius and it's x-y distance from the wall then you can push it perpendicular y units and it'll be in the right spot.

I really wish I could draw a diagram.

Thanks, that's what I was trying to say last post. I drew up a diagram for anyone else interested/to help myself think too.



Something that would also be interesting to test is for me to find that code snippet I used to have to find the normal at any point on an image. You would just specify a point and it would scan through the image/surface to find the normal of that point, it would be very useful for later projects using non-square objects.

Vino
Aug 11, 2010
What kind of image? I'm a bit confused because I don't know why an image would have a normal unless it's a normal map.

Anyway try this:



Instead of the "pushing out" algorithm. When you're simulating the object, you find the point where it intersects with another object. Then you change the velocity of the object depending on what it hit (slide for a wall, bounce for another circle) and do the operation again until it hits nothing or until it hits something 3 or 4 times. I think this will get you a more accurate movement simulation.

Or you can just do the pushing out method.

Jewel
May 2, 2009

Vino posted:

What kind of image? I'm a bit confused because I don't know why an image would have a normal unless it's a normal map.

Anyway try this:



Instead of the "pushing out" algorithm. When you're simulating the object, you find the point where it intersects with another object. Then you change the velocity of the object depending on what it hit (slide for a wall, bounce for another circle) and do the operation again until it hits nothing or until it hits something 3 or 4 times. I think this will get you a more accurate movement simulation.

Or you can just do the pushing out method.

Nope, it wasn't getting a normal per-se but instead pixel-scanning a circle around the point and working out a normal based on that, it was a really cool script. Also, your way would be a little hard to implement with rotated walls wouldn't it? My way should still be able to do the same thing and it should work the same I think.

Vino
Aug 11, 2010

Tw1tchy posted:

Nope, it wasn't getting a normal per-se but instead pixel-scanning a circle around the point and working out a normal based on that, it was a really cool script.

Your... level is stored in an image? *shrug*

Tw1tchy posted:

Also, your way would be a little hard to implement with rotated walls wouldn't it? My way should still be able to do the same thing and it should work the same I think.

No I don't see why it'd be hard. In fact I think it would be more robust in the case of multiple, rotated walls.

Jewel
May 2, 2009

Vino posted:

Your... level is stored in an image? *shrug*

Haha no no, not for anything soon, just saying for random testing and/or playing around with things later.

I'll try your way after I get mine working and compare precision.

Jewel
May 2, 2009

Ugh ok I've been trying to get it working but honestly I'm just bad today. I can't work out how I'd get the normal of the object I just collided with, anyone have some good documents about that?

Vino
Aug 11, 2010
How are you storing your wall data?

If you have a line segment with two points a and b then your normal would be

code:
v = a - b
normalize v
normal = (-v.y, v.x);
I think? Looks right.

Jewel
May 2, 2009

Vino posted:

How are you storing your wall data?

If you have a line segment with two points a and b then your normal would be

code:
v = a - b
normalize v
normal = (-v.y, v.x);
I think? Looks right.

A "wall" in my case is just a rotated rectangular sprite (think sandbags in a war), so how would you recommend I change the system around to work?

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
If your wall sprites are just rotated rectangles, why not represent them as rotated rectangles for the collision detection instead of using per-pixel collisions?

Make a rectangle the same height and width as your sprite, then translate and rotate it into the same position as the sprite. Now you know the positions of the corner points and can use the normal vector calculation Vino suggested.

Vino
Aug 11, 2010
Yes I agree. drat now that I'm actually looking at the formulas, 2d poo poo looks so easy compared to 3d. No rotation matrices, all of the math is simple. Maybe I'm in the wrong business.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Vino posted:

Yes I agree. drat now that I'm actually looking at the formulas, 2d poo poo looks so easy compared to 3d. No rotation matrices, all of the math is simple. Maybe I'm in the wrong business.
Why would you not use rotation matrices in 2D?

Morpheus
Apr 18, 2008

My favourite little monsters

Orzo posted:

Why would you not use rotation matrices in 2D?

Why would you? A single value would be sufficient, wouldn't it?

Edit: Oh wait you mean multiplying each point by a matrix to rotate...that works too.

haveblue
Aug 15, 2005



Toilet Rascal

Morpheus posted:

Why would you? A single value would be sufficient, wouldn't it?

Edit: Oh wait you mean multiplying each point by a matrix to rotate...that works too.

What if you want to both rotate and translate the point, or build an articulated character using 2D skeletal animation? Matrices still have the same advantages in 2D.

Jewel
May 2, 2009

My my, I use gamemaker to try out and prototype any formulas I need since it's much faster to code/get running (since I used it a lot as a kid), and I've worked out how to detect if two line segments are intersecting and where they are intersecting by mashing up some math formulas into code. Is this right, since it seems like there's a lot of math involved whereas I didn't expect there to be this much? Is there a faster, more efficient way?

code:
x1 = p1.x
y1 = p1.y
x2 = p2.x
y2 = p2.y
x3 = p3.x
y3 = p3.y
x4 = p4.x
y4 = p4.y

//CHECK POSITION OF INTERSECTION FOR LINES

draw_line(x1,y1,x2,y2)
draw_line(x3,y3,x4,y4)

ax = ((x4-x3)*(y1-y3)-(y4-y3)*(x1-x3))/((y4-y3)*(x2-x1)-(x4-x3)*(y2-y1))
xint = x1+ax*(x2-x1)

ay = ((x2-x1)*(y1-y3)-(y2-y1)*(x1-x3))/((y4-y3)*(x2-x1)-(x4-x3)*(y2-y1))
yint = y3+ay*(y4-y3)

//CHECK INTERSECTION FOR LINE SEGMENTS

Ex = x2-x1
Ey = y2-y1

Fx = x4-x3
Fy = y4-y3

Px = -Ey
Py = Ex

h = ( (x1-x3)*Px + (y1-y3)*Py ) / ( Fx * Px + Fy * Py )

Ex = x4-x3
Ey = y4-y3

Fx = x2-x1
Fy = y2-y1

Px = -Ey
Py = Ex

h2 = ( (x2-x4)*Px + (y2-y4)*Py ) / ( Fx * Px + Fy * Py )

if h2>0 and h2<1 and h>0 and h<1{
    draw_text(0,0,"INTERSECT")
    
    draw_line(xint,yint-20,xint,yint+20)
    draw_line(xint-20,yint,xint+20,yint)
}
Edit: Also since gamemaker is really basic it almost looks like psuedocode :3:

Edit2: This is what I'm trying to accomplish a simpler way (if any):

Jewel fucked around with this message at 07:32 on Dec 18, 2010

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
The part you use to check if the intersection point is actually on the line segment looks overly complex. Can't you just check that xint is between x1 and x2, and also x3 and x4?

Jewel
May 2, 2009

HappyHippo posted:

The part you use to check if the intersection point is actually on the line segment looks overly complex. Can't you just check that xint is between x1 and x2, and also x3 and x4?

Seems not since you don't know which point comes first? I have no idea, just from googling around right now it seems the solution is the one I did. The reason it looks more complicated too is because gamemaker has no vectors so I had to simplify the dot products.

The original code would have looked like this:

code:
E = p2-p1
F = p4-p3
P = -E

h = ( (p1-p3)*P) / ( F * P)

E = p4-p3
F = p2-p1
P = -E

h2 = ( (p2-p4)*P) / ( F * P)
Where h and h2 is the amount you have to times the length by to intersect, which means if it's under 1 and over 0 then it's intersecting.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Which point comes first is a simple comparison though.

Jewel
May 2, 2009

HappyHippo posted:

Which point comes first is a simple comparison though.

That's what I'm trying to ask though, does doing this math of mine 100~ times per frame lag more than a comparison check, or does it not matter?

Vino
Aug 11, 2010
Okay 2d math maybe has rotation matrices but they're going to be a shitload simpler than 3d rotation matrices. The way I got that formula for normal of a plane in 2d was by simplifying a 3d cross product into 2d. (It was the first and easiest way I could think of.)

schnarf
Jun 1, 2002
I WIN.

Tw1tchy posted:

That's what I'm trying to ask though, does doing this math of mine 100~ times per frame lag more than a comparison check, or does it not matter?

It doesn't really matter; computers are fast and can do arithmetic way faster than we can wrap our heads around. Write whichever is the cleanest to understand, and then later on if things are really slow you can profile and see what the bottleneck is, and at that point, worry about optimizing whatever shows up as a hot spot in the profiler.

HIERARCHY OF WEEDZ
Aug 1, 2005

Does anyone have experience working with Ogre and ODE (and maybe OgreODE)? I'm trying to get a first-person camera system going, something very simple that responds to the terrain under it, can go up slopes of certain angles but not steeper ones, and something that allows the camera to sit in it and rotate/move in the correct orientations. I've tried patching things together from the OgreODE demos and tutorials, and I'm nearly there, but moving the mouse to rotate the camera causes it to occur at a skew and on two locked axes (gimbal lock?) instead of being freeform, and more often than not the entire construct seems to be leaning to one side instead of being kept upright. I have a lot of code so I'm not sure how much of it is relevant to post, but here's the majority of the Player class that implements the construction of the first person system: http://pastebin.com/K0DVNsCD

EDIT: Solved -- something like m_Camera->lookAt before setting up it's positioning and relative pitch seems to gently caress it up. With that fixed, I'm looking straight ahead, and can look around normally.

HIERARCHY OF WEEDZ fucked around with this message at 20:43 on Jan 7, 2011

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Here is a little problem I'm having that someone here might actually find fun, so I figure I'll throw it out there.

I'm designing a 2D level editor. Entities are essentially textured rectangles with Scale, Position, and Rotation. I am now implementing where the user can click and drag 'handles' to resize the rectangle; the handles snap to grid points. Unfortunately, you can't just move the target vertex by itself, since these are always rectangles and not arbitrary quadrilaterals.

For example, let's say the user is dragging the 'Top Left' vertex around to make the entity bigger. Rotation is preserved, and the position of the 'Bottom Right' vertex is preserved, but the 'Top Right' and 'Bottom Left' vertices must move to keep the shape a proper rectangle.

I suppose the easiest technique here is to write a function that, given the position of the 'Top Left' and 'Bottom Right' vertices as anchors, and a rotational value, calculates the final Position (x,y) and Scale (sx, sy) of the new shape. I'm going to see what I can come up with, but my math is a little rusty here, does anyone know a way to do this easily? Or perhaps a better technique than what I'm suggesting?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Orzo posted:

I suppose the easiest technique here is to write a function that, given the position of the 'Top Left' and 'Bottom Right' vertices as anchors, and a rotational value, calculates the final Position (x,y) and Scale (sx, sy) of the new shape. I'm going to see what I can come up with, but my math is a little rusty here, does anyone know a way to do this easily? Or perhaps a better technique than what I'm suggesting?
The easy solution to me (probably not the fastest but it's for an editor so who cares) would be to take your 'worked on' coordinates, offset them such that the opposite corner or hotspot or whatever your anchor point for scaling is is effectively (0,0), then rotate your working coords by the inverse of your current rotation, and that'll give you an x,y that's the new scale factors (possibly after you divide by the original width and height, depending how you're working).

As for the final position, that depends how your objects are anchored - center, a hotspot, the bottom left (untransformed) corner? Regardless it should be pretty easy to get the new coordinates given that you have your worked-on corner's coordinates, a scale and a rotation. It sounds like you might still need to decide on how a rectangle is anchored, which would be your first priority.

Adbot
ADBOT LOVES YOU

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
The anchor is always the center of the rectangle. Thanks for the input, seems like the solution to every problem is 'convert it to local coordinates' and work from there. Any other suggestions are welcome, I suppose I'll mess around with this on paper.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply