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.

Newcomers DBPro Corner / dbpro jumping

Author
Message
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 5th Jan 2009 19:22
Hi can somebody explain to me how the gravity work cuz i wanna make my player be able to jump very height like a ninja or superman or something..
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 6th Jan 2009 14:56
come on pleaase help me
I used to help people when I know what they're asking
DsarchyUK
15
Years of Service
User Offline
Joined: 21st Nov 2008
Location: UK
Posted: 6th Jan 2009 23:21 Edited at: 7th Jan 2009 11:25
Are you asking for a definition of Gravity? Well its a constant force that is applied to objects within the game loop.
In a simple example inside the main loop you might have a sprite (2d) like so:



"Gravity" can be applied to the YAxis using the following in the Game loop:



This will increase the YPos by 1 every time the game loops, effectively pushing the sprite down.

A forum search would give you more than enough information you need. Search either "Gravity" or "Jumping".

If you want a faster answer then try to show that you have made an effort yourself. A bit of code will encourage people to answer. Using words such as 'cuz', 'wanna' doesn't help either, a little effort in your grammar shows that you have taken then time in checking what you have said and shows that you, at the very least, care about what you have said. Firefox has build in spell check nowadays so there is no excuse .

I can see that, like myself, your new so don't take this as a 'flame' but just a little advice to get quicker responses in the future.

Regards,

EDIT: Said all that and didn't upload the code. This example shows gravity and jumping, hit space to jump:



http://dsarchy.deviantart.com/
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 7th Jan 2009 00:20
To expand on the code posted by DsarchyUK, basically you're going to have an acceleration variable, a velocity variable, and a position variable. The velocity describes the speed of your player and acceleration is the amount the speed increases/decreases each frame, the position is the position of your player and the velocity is added to this position each frame. When your player begins the jump, and inital velocity is set, which you can call the jump velocity, and each frame the acceleration caused by the gravity will lower this velocity by 9.8m/s (or whatever you want your gravity to be).


the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 7th Jan 2009 09:50
allright thanks

Login to post a reply

Server time is: 2024-11-16 01:09:48
Your offset time is: 2024-11-16 01:09:48