Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411918 Posts in 69431 Topics- by 58479 Members - Latest Member: KriegsHetzer

June 11, 2024, 06:54:42 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Flixel and other 2d plane physics applied to Circles
Pages: [1]
Print
Author Topic: Flixel and other 2d plane physics applied to Circles  (Read 2078 times)
shadowdim
Level 1
*



View Profile
« on: September 02, 2010, 12:13:03 PM »

Hi there!

I'm working on a platform game in Flex. I'm not a physics/maths nerd, and building my own engine is thus out of question, that's why I played with Flixel these last two weeks. The thing is, while the gravity, acceleration and such are really well made in Flixel, they only work on a plane surface. I want my game to be set on different planets. Round ones. and the character would run around.

I've tested many things, but I'm not satisfied: this round-planet-thing is what makes my game original (apart from that, it's "yet another platformer".)

I then thought of this:
Using Flixel's physics, calculating x, y, acceleration, velocity, etc... WITHOUT displaying it. I would instead transform the coordinates given by the engine, to make everyting arc around my circle. I'm not sure if this will be easy or not, but it seems like standard trigonometry to me.
Schema:

(light colors = not displayed, but still calculated and processed in real time)

Am I doing it right?


tl;dr: 2d plane coordinates to 2d around-a-circle coordinates = yesyes or nono?
« Last Edit: September 02, 2010, 12:21:17 PM by shadowdim » Logged
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #1 on: September 02, 2010, 01:07:46 PM »

Have you considered using box2d? This guy has some good tutorials for it...

http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/

and here's the official website...
http://www.box2dflash.org/
Logged
shadowdim
Level 1
*



View Profile
« Reply #2 on: September 02, 2010, 01:23:23 PM »

I've heard of it, but it's too complex for a platformer. Plus it's a lot less user-friendly.
Logged
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #3 on: September 02, 2010, 01:36:19 PM »

Hmm, I suppose those are valid points, but it can be quite easy once you get used to it. I found it easier to get to grips with than flixel tbh.
Logged
Sam
Level 3
***



View Profile WWW
« Reply #4 on: September 02, 2010, 02:38:11 PM »

Neat idea!  Unfortunately I don't think it's going to work out.

Consider if you want to have two pillars in your world:



They should appear as they do on the circle-world of figure 1:  Their bases are touching, but because they're on the curved surface they will not touch at their top - you can fit a pea between them.

Figure 2 shows how they'd be modelled in a flattened out world.  Note the lack of space for a pea.

You could model the circular world correctly using a plane, as shown in figure 3.  That would require all your shapes to be distorted so that they're narrower at the top (exactly how much narrower will depend on the radius of the circle-world), and for moving objects to be dynamically shrunk as they move further from the ground.  Which is certainly not the simple physics solution you're looking for.


My own solution would be to model it as the curved world that it is.  Store velocity and position for the player as normal and instead of applying a standard downward gravity force, I'd apply a force that pointed from the player's current position toward the middle of whatever planet she's closest to.

I'm not familiar with what physics stuff Flixel can cope with.  The main feature you'd need to implement my method would be testing for collisions between rotated rectangles.
Logged
Draknek
Level 6
*


"Alan Hazelden" for short


View Profile WWW
« Reply #5 on: September 03, 2010, 04:12:10 AM »

I agree, I don't think this is the simple solution you're hoping for.

My own solution would be to model it as the curved world that it is.  Store velocity and position for the player as normal and instead of applying a standard downward gravity force, I'd apply a force that pointed from the player's current position toward the middle of whatever planet she's closest to.

I'm not familiar with what physics stuff Flixel can cope with.  The main feature you'd need to implement my method would be testing for collisions between rotated rectangles.
This is what I would do, although I would probably make the collision shapes for the players circular to make testing collisions easier.
Logged

shadowdim
Level 1
*



View Profile
« Reply #6 on: September 03, 2010, 09:23:11 AM »

Damn, I didn't think of the fitting-a-pea problem.

Appplying a force towards the center of the planet should do the trick, but rotated rectangles are scaring me. kind of.
Logged
st33d
Guest
« Reply #7 on: September 04, 2010, 05:36:47 PM »

How about accepting the fact that you're on a circle and making the rectangles have a curved top. Like they were in perspective and their vanishing point was in the center of the circle:

aaand I can't find an image that describes what I mean...

The collision would then be very simple (you'd be treating the circumference as a straight line and obstacles would stick vertically up out of it).

And it would give the art work a weird theme of the blocks being exaggerated.
Logged
shadowdim
Level 1
*



View Profile
« Reply #8 on: September 05, 2010, 04:54:37 AM »

But then comes the rotation.

http://megaswf.com/serve/44016/

I'm not even using Flixel's gravity components here. The planet is moving instead of the player. Moving the enemy and colliding with the player might be a hassle.

And finally, Flixel's rotation and sprite deformation is obviously horrible to the eye.

What now?
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic