We get it. We use ad blockers too. But GameDev.net displays them so we can continue to be a great platform for you.
Please whitelist GameDev.net and our advertisers.
Also consider a GDNet+ Pro subscription to remove all ads from GameDev.net.
Jump to content
Posted by Zippery on 22 May 2013 - 08:32 PM
Posted by Zippery on 14 May 2013 - 08:17 AM
I'm currently writing a 2d platformer for Android smartphones / tablets and I have a question regarding gravity.
I read up a bit before I applied gravity and from what I could tell, it seemed that gravity should be applied 'constantly' to characters (Like it is in real life).
By this, I mean, if the character is standing on a solid floor/platform, gravity will still be pulling him down.
My collision detection, will predict that his next position will be 'in' the platform and correct it before rendering. This way, when he isn't on a platform, he will just fall without me having to do anything extra.
However, I read an interesting article about how Sonic was made and it states that:
(Of gravity) This value is added to Y speed in every step in which Sonic isn't on the ground.
So I'm guessing they have a boolean value 'gravity' and just switch it true or false depending on when they want the gravity to be applied. (So false when on floor/platform, then switch to true when not).
I'm just wondering which of the two methods do you advocate and why? Which one would be easier to work with and why?
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.