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 / Jumping won't cooperate

Author
Message
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 2nd Nov 2004 08:42 Edited at: 2nd Nov 2004 17:06
I've looked all over the forums and codebase for answers, but I can't seem to get my object to 'jump' when I use this code

REM jumping
if spacekey()=1 and jump=0
jump=1
jumpvel#=0.05
gravity#=-0.005
endif
jumpvel#=jumpvel#+gravity#
y#=y#+jumpvel#
REM stop back on the ground
if y#<=0.0
y#=0.0
jumpv#=0.0
gravity#=0.0
jump=0
endif

if speedr#=<0.0
speedr#=0.0
endif
if speedl#=<0.0
speedl#=0.0
endif

position object 1,object position x(1)+speedr#-speedl#,object position y(1)+y#,0

The object simply moves upwards on the Y axis and then stops. I had it fall due to gravity before, but it continued on past the y axis despite my code that sets all of the values to zero when the object returns to the x axis...

What could be the problem?

Neeeeeeeewom!
Cian Rice
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 2nd Nov 2004 08:48
Wish I could explain what the problem is in your code, but tifu made a platforming engine with some nice jumping that required falling to equal 1 for the player to come back down, could that be something you need for your code? Pretty much when you are going up falling would have to equal 0 and when you want to come down falling would have to equal 1.

There is only one way to package shaolin: Shaolin Soccer...
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 2nd Nov 2004 08:55 Edited at: 2nd Nov 2004 08:55
Sine waves are your friends.

Quote: "I've seen the word programming and I'm not sure what it means. Anybody please explain?"


Quote: "We shouldn't sacrifice the truth to preserve "balance"."
Hop a long
20
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 3rd Nov 2004 12:00 Edited at: 3rd Nov 2004 12:01
Hattori

Here's something to look at:
http://www.geocities.com/hifin2003/jump.html
This might be more than you need because it also involves collision.

If you're jumping on a matrix try:
http://www.geocities.com/hifin2003/matrix_jump.html

Arrays are used here to take a closer look at the math:
http://www.geocities.com/hifin2003/jump-math.html

Show us the next thing you do with your code.
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 3rd Nov 2004 16:46 Edited at: 5th Nov 2004 16:48
I've got it working now, using info I learned from the original posts I was going off of and those wonderful tutorials you gave me. Some of each of them didn't work or looked to rigid but I fiddled enough that it works perfectly now, and smooth as possible. Take a look:


Here's all the code if you wanted to test it or anything:


Much thanks!

Neeeeeeeewom!
Hop a long
20
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 5th Nov 2004 09:08 Edited at: 5th Nov 2004 09:13
Looks great. Thanks for sharing your code. Nice organization, it's a pleasure to read. I'll have to try it out.

Login to post a reply

Server time is: 2024-09-23 04:28:37
Your offset time is: 2024-09-23 04:28:37