2D Side Scrolling Motorcycle Collision Response
Author |
Message |
Silinter
|
Posted: Sun Jul 05, 2009 2:52 pm Post subject: 2D Side Scrolling Motorcycle Collision Response |
|
|
So, there is a type of game which roughly includes the player who is in control of a bike/motorcycle, and he is to overcome obstacles to reach a goal.
This is usually done by having the up arrow key act as a throttle, which causes the back wheel to rotate, which causes the bike to move in the direction of the friction when in contact with a surface.
The player is able to shift himself (or lean) backward/forward which enables him to move through the level. He is also able to switch directions and break/reverse with their own respective keys.
You've probably played a game similar to the above description once in your life. One of the earliest examples I can think of right now is Elma (Elasto Mania) made by Bal?zs R?zsa [link], made back in 2000. Now there are flash versions of the game, and even mobile versions (Bike or Die/MotoGear for Palm OS).
I was thinking of making a similar game to Elasto Mania, where you are able to do much the same feats. Elma claims to be based on a real physics model, but there is no information as to back up this claim. Nevertheless, it's a solid game that even I've been playing since I was a kid.
Now, what I'm thinking is the collision detection is done through a line vs point detection for the wheels, and the level is a series of simple polygons, (in Bike or Die it doesn't matter whether they're simple polygons, but in Elasto Mania and MotoGear it does) which in turn is made of an array of points. I'm thinking they speed up the collision detection with quadtrees. They all have a system where you are to retrieve items (flags/gears/apples) and then touch the finish item to complete the level (chequered flag/flower). What I can't get my head around is the collision response and the friction system. Bike or Die, being the only one of the three to still be in development, has a choice of a slippery surface, normal surface and sticky surface. These, of course, change the way the wheel interacts with the ground, whether it be sliding even though the brake is active, or being able to scale walls like spider-man.
So my question is this: Where can I find a good source of information which explains collision response and a friction system that's involved in these types of games, and where can I find a good tutorial on node-based quad trees?
I'm setting out to program this in C++, and I have a good understanding of inheritence/polymorphism, most STD/STL commands, SDL, SPriG (SDL Primitive Generator), as well as Irrlicht (an unrelated 3D engine that handles collision response between 3D meshes and arbitrary ellipses, as well as key stroke input and oct-tree creation), so I don't consider myself a beginner. If possible, the theory explanation would be great, and anything in C++ that's related would be even better. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Silinter
|
Posted: Tue Jul 07, 2009 7:59 pm Post subject: Re: 2D Side Scrolling Motorcycle Collision Response |
|
|
Alright, so I looked into Box2D, a 2D physics library, which, by default, works with motors and convex polygons. I've also looked into rendering with OpenGL, as I'd like some hardware acceleration if possible.
Now, the predicament that I'm faced with is that Box2D works with meters. It takes in meters and spits out the polygon vertex coordinates in meters, and works best with polygons that are between 0.1 and 100 meters in size.
However, when you are faced with rendering the polygons, 1 meter is (without scaling) 1 pixel. This is obviously not right. They mention on the website that 1 meter is around 30 pixels. Now, I switched over to OpenGL rendering because they mention on their site's wiki that "with the right viewport settings, OpenGL will scale it for you". How would you get OpenGL to scale it automatically?
I've only picked up OpenGL yesterday, but it's not as complicated as I thought it would be, (for drawing 2D polygons and textures anyway) however, I can't find any source of information which would help me. Would it involve messing with the matrix? I have no clue.. I'll dig around but I thought I'd ask anyway. |
|
|
|
|
|
|
|