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 / What is the easiest way to make a sprite jump?

Author
Message
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 28th Jul 2008 00:13
Hi,

I only have been working with sprites lately, but I just realized I have to make him jump to. But when I acutally tried to write the code out, I was like...how the heck do I get this to work. How do I get the sprite to jump up and come back down. I currently don't have any images or anything so there is no collisions and stuff. I only have the sprite at 350 on the y axis.

Thanks
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 28th Jul 2008 01:26
A loop of repositioning the sprite by a small amount until it's as high as you want, then do the opposite.. Just mess with it a bit. You'll get it.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 28th Jul 2008 12:12 Edited at: 28th Jul 2008 12:13
really you should, as soon as the jump button is pressed, make his y position go up by a value every frame, the value being 9.8m/s squared less than the last, if you get me.

In the first frame he goes up at say 30 m/s (this is stupidly high, dont use it), divied by the frame rate. I will assume the frame rate is 1 FPS for simplicity. Next frame he goes up a further (original amount - 9.8 ) divided by frame rate, which in our case is 20.2. Next frame he goes up 10.4, then 0.6, and then he starts falling down again using the same system, he goes up by -9.2. This keeps happening until he hits the ground.

This is because acelleration on earth due to gravity is around 9.8 m/s. I havn't taken into account air resistance, so this assumes your character is completely frictionless.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 28th Jul 2008 20:47
Quote: "This is because acelleration on earth due to gravity is around 9.8 m/s. I havn't taken into account air resistance, so this assumes your character is completely frictionless."


Slippery little devil, eh? For short distances in air friction shouldn't be a consideration. The amount of friction will be dependent on the instantaneous velocity, the higher the velocity the greater the resistance. If there's not much velocity involved then resistance is futil...... uh, negligible.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 28th Jul 2008 20:51
I have a feeling the OP doesn't really care about this level of detail.

Essentially, you need to make the sprite slowly go up, then, after a point, go back down.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo

Login to post a reply

Server time is: 2024-09-30 03:20:54
Your offset time is: 2024-09-30 03:20:54