Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2D Gravity Question

Author
Message
Foxy
20
Years of Service
User Offline
Joined: 4th Jan 2005
Location: The Dale, South Australia
Posted: 24th Jan 2005 15:14
I'm working on a small 2D system to figure out collision and gravity in 2D games. I've come this far with my code and I cant get any further. My code so far has the collision system working fine but I can't apply gravity to it.

My code so far is:


I've tried using a variable system to reduce the y pos of the sprite and slowly increase it again but that didn't seem to work. If anyone knows of any code I could put in there to get it working it would be appreciated.

Durdge39 - Leading the way into the fridge!!!
pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 24th Jan 2005 20:35 Edited at: 24th Jan 2005 20:38
You already have gravity in your example, when you press the downkey, so heres your gravity code



[Edit]

Just found some code I made in another post which is a little more complex but is about the same thing - its only fo DBP but can be easily modified for DBC



Hope it helps you

[/Edit]

Foxy
20
Years of Service
User Offline
Joined: 4th Jan 2005
Location: The Dale, South Australia
Posted: 24th Jan 2005 21:39
Thanks for that. Will have a good look at that code. The downkey code was a leftover from when I was getting the collision right, I should've really cleaned that up though .

Durdge39 - Leading the way into the fridge!!!

Login to post a reply

Server time is: 2025-05-17 03:18:03
Your offset time is: 2025-05-17 03:18:03