# Tutorials for vector based platform gaming

This topic is 4058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, I have recently worked on a little demo that bounces some objects around the screen, off of a user-created series of lines. Link to program to explain it a little better. This is all fine and good for either a 2D top-down game or a 3D game where the game field is completely flat or close to it (No elevation). What I'm looking for are good resources on how to start treating this like a 2D Super Mario side-scroller. In other words, I'd like to start putting in gravity and allow jumping, climbing and falling down slanted walls and whatever else I've missed. I'm looking for any relevant resources to begin working on this. My apolgoies if the search for such resources is trivial; I just don't know the exact name of the information I'm searching for. Any help you guys could give me is as always much appreciated!

##### Share on other sites
To implement gravity, simply increase each of the objects velocities in the downwards direction by a constant value at set intervals (in the real world, it would be 9.8 m/s every second, or equivalently 0.196 m/s every 20 ms -- or whatever your refresh rate is).

As for the objects sliding down the 'lines', you would need to implement some sort of frictional/damping force. But eitherway, you'll find that the objects will merely bounce their ways down the lines, rather than slide.

To make things more realistic however, you could implement a spinning motion of the objects. To model that, you'd generally deal with the angular momentum and moment of impulse.

So, suppose your sphere initially has angular velocity w, radius r, mass m, moment of inertia I, and it is travelling with a velocity u (which is a 2D vector). Suppose it collides with a surface with a unit normal n, and which has a coefficient of restitution e.

Then the final velocity and angular velocity (immediately after collision) will be:

v = T(u dot T) + n(e*u dot n)
W = w + r*m*(u-v)dot(T)/I

Where T is defined like so:
If n=(x,y), then T=(-y,x).

(Assuming I haven't made any mistakes. I'll recheck the math when I get back from work)

##### Share on other sites
http://jnrdev.72dpiarmy.com/

##### Share on other sites
Thanks for the help. The link is exactly what I was looking for.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632631
• Total Posts
3007528
• ### Who's Online (See full list)

There are no registered users currently online

×