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 / Sprite gravity.

Author
Message
Kamaki
19
Years of Service
User Offline
Joined: 26th Oct 2005
Location:
Posted: 28th Oct 2005 22:34
I was wondering how you could make a sprite have gravity? Is anyone able to show me a example or something along those lines? If they wouldn't mind I would also like to know how to make my sprite jump? Which is really the only reason I want gravity (^_^).
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 29th Oct 2005 00:57
What you would do is have a value for the y position of the sprite. then you would have a value that increases the y position. When you press the jump button you get a ground value. That is the y position the sprite was at y. Also when you press the button you set the jumpspeed# variable to something like 2. Then if the jumpspeed# > 0 or the y position of the sprite is greater than ground# you decrease jumpspeed# by something like 0.1 and increase the yposition of the sprite by jumpspeed#.

Following this?

NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 29th Oct 2005 08:08
Kamaki,

Place the code below into your editor and run it. It is an example of a jumpable and moveable sprite. Enjoy. Study the code.





+NanoBrain+
Kamaki
19
Years of Service
User Offline
Joined: 26th Oct 2005
Location:
Posted: 29th Oct 2005 11:55
Thanks for the Code NanoBrain! I'l learn from it like you said.

Login to post a reply

Server time is: 2024-11-27 14:21:04
Your offset time is: 2024-11-27 14:21:04