Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] J2ME: Thrust and Gravity...

Started by RageMatrix Feb 25, 2005 at 4:58 AM 1 replies 850+ views
Original Post
RageMatrix
RageMatrix
I'm trying to implement the following and have no real idea on how to do this, especially because of the lack of floating point under J2ME MIDP1.0 and also because my math sucks. What I want to do is have a sprite at the bottom of the screen that when you press UP thrusts into the air up the Y axis up to a maximum acceleration. When letting go of the UP button, I'd like him to fall back down again until he either hits a platform or the "ground" which is (getHeight()). Any pointers, hints, advice on how to achieve this? This is actually (from my point of view) the hardest part of my game.....after this, its plain sailing. Thanks.
Skizz
Skizz
Use fixed point maths. You will need to be very careful with the range of values you use - it can be very easy to overflow the fixed point range. Search google/gamedev for fixed point - it has been covered a lot.

Skizz
Thygrrr
Thygrrr
You can also just add integer values to integer velocities to represent acceleration. Increase the speed by 1 every 100 ms: Voila, pretty close to an acceleration of 9.81 units per second squared.

But fixed point is the bestway to go. Very easy, fairly efficient, and a lot of fun to use!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.