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.

Dark GDK / 2D Gravity?

Author
Message
SpaceMan Infinity
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location:
Posted: 30th May 2008 01:59
I'm going to make a 2D fighting game, how to make gravity and jumping? are we need to use math functions to do that?
deadlyduck
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 30th May 2008 03:42
I presume you are making a platform game?

If so you will need to test if your player sprite is standing ontop of a platform, if not then decrease the sprites hight on the screen.

you can start with a small decrement and build up2 a higher max fall speed.

you can jump by adding a negative fall, err that dosn't sound right, I'll write out a simple example

Fall =1
if(ManIsFalling) {

Fall = Fall + FallIncrement;
}
deadlyduck
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 30th May 2008 03:51
err not sure what key I just hit but it posted it while I was typing, try again



I haven't put any specific code here, this is just to give you an idea

If the Man is falling he starts of falling slowly, building speed quickly till he reaches a max (terminal) velocity.

If the man jumps, he gets a negative fall speed, and flags that he is now falling, the fallspeed(jump) will decrease and he will quickly fall again (hopefully onto the ground)

you will have to test for a sprite under his feet

Is there a sprite at Manx+(Man.width/2),Man.y+Man.height? if no then set falling flag.

hope this helps

Login to post a reply

Server time is: 2024-09-29 21:14:51
Your offset time is: 2024-09-29 21:14:51