JumpThrough And JumpHeight

by Crazy Star


Posted on December 29, 2006 at 7:21 PM



This is actually 2 examples merged into one:

<b>Jump through platforms</b>
and
<b>jump x pixels high</b>.

The second thanks to the equation that GearGOD showed to me.


Controls:
left/right - move left/right
up/down - jump up/down
F4 - change resolution

Enjoy,
-SpectreNectar


sirxemic commented December 29, 2006 at 7:38 PM
Hmm... simple, but with some mistakes: the character jumps at the beginning 34 pixels high, not 32 as you probably wanted (jump x pixels high). And I also noticed that when you jump through a platform, you jump 37.44 pixels high. So I guess the example is just a jump through example.
Crazy Star commented December 29, 2006 at 8:22 PM
not 32 as you probably wanted
C-Ator9
It's supposed to be 32*jumpLevel+2. The extra 2 is for making it look better - you can change it to be the exact height of the blocks but it isn't recommended:



As I mentioned before, an exact solution to this equation is going to be different from the value GM will come to because it's approximating this differential equation at 30fps which is a fairly pathetic resolution. The faster the jump velocity, the greater error you can expect. I suggest you just deal with it by allowing for that error in gameplay.

Edit: here's a better explanation:

The curved line is what the motion should be, ang the solution of the projectile's motion.
The dots are where GM sees the instance at 30fps, merely an approximation of the above.
The red lines are your error.
Lower the fps or increase the velocity, and the error climbs.
GearGOD

I see. But though I'm glad I understand why it didn't work it doesn't reall matter now as I found a solution to it. I now use
CODEjumpPow = sqrt(2*gAdd*height)-gAdd/2;
Which make the difference between my calculated distance and my expected distance close to or exactly zero with all the values I tried. I guess that is because the number of steps before gravity reaches 0 is always even or always uneven for some odd reason, and that is the opposite scenario of what would make the equation give 0.
SpectreNectar

WHICH MEANS that if you set the height to 32 then you can expect to jump maybe 31.998px which is unfortunate but unavoidable. Of course you could always set the height to 32.01 ...



I also noticed that when you jump through a platform, you jump 37.44 pixels high.
C-Ator9
I would like very much for you to prove how you discovered this. By the looks of it you're right though *goes back to code editor*.


And yeah it's pretty basic.
Crazy Star commented December 29, 2006 at 9:46 PM
Why does it say that there's 5 comments when theres only 3? A site developer would probably want to look into this.
Anyways I thought I figured the bug out but apparently I didn't.
If you want to help me out then here's a debuggin version (the version that I thought was bug free but wasn't after all)

<a href="http://www.64digits.com/download.php?name=jumptrough2.gm6&id=13046">http://www.64digits.com/download.php?name=jumptrough2.gm6&id=13046</a>;
Iluvfuz commented December 30, 2006 at 3:14 AM
Collision problem! Good example, even so the math is a little bit off, but I personally don't think anybody should really care about 2 pixels off... 8/10
DarkSoulcalibur commented December 30, 2006 at 11:08 AM
hm...?... i suppose this could be pretty useful, nice work, 8/10
Crazy Star commented December 30, 2006 at 11:57 AM
Iluvfuz:
Could you be more specific about the collision problem...?
People might care about the 2 pixels if those are crucial to the type of platform game they are creating.

DarkSoulcalibur and Iluvfuz:
Thank you.
Crazy Star commented December 30, 2006 at 1:04 PM
ALMOST works now. Just need to fix that annoyance of a collision problem.
http://www.64digits.com/download.php?name=jumptrough2_debuggering.gm6&id=13090
sirxemic commented December 30, 2006 at 2:30 PM
I would like very much for you to prove how you discovered this. By the looks of it you're right though *goes back to code editor*.
Quote
draw_text(x+40,y,string(minY-ystart))
Where minY is the smallest y-value the character has had.
Crazy Star commented December 30, 2006 at 5:37 PM
I think it works now.
http://www.64digits.com/download.php?name=jumptrough2o.gm6&id=13101
Can you find any more bugs in this?
Thank you all for helping me find bugs so far
Juju commented December 30, 2006 at 7:44 PM
No bugs. It's beautifully programmed. 10/10
melee-master commented December 31, 2006 at 8:39 AM
That was very good! Definitely a 10/10.
MooshteRahoo commented December 31, 2006 at 2:51 PM
pretty cool.10/10
Crazy Star commented December 31, 2006 at 3:35 PM
Whoa thanks a bunch you three!
I've been working on adding solid obstacles. Have a looky here:
http://www.64digits.com/download.php?name=jumptrough3_debugging_solids7.gm6&id=13149
It doesn't quite work though:
http://www.64digits.com/download.php?name=jumptrough3_solids.gm6&id=13150
But I'm through working any more on this today... so. Feel free to give some info on the bugs that you find maybe with a .gm6 simplifying it. That'd be great actually.
Crazy Star commented January 28, 2007 at 6:11 PM
FINALLY WORKS!
Here's the old file:
http://www.64digits.com/download.php?name=jumptrough.gm6&id=14452