1
Axe / Jumping code?
« on: February 19, 2016, 02:10:48 pm »
I'm trying to make a platformer - and for the most basic platformer ever, you need jumping. I tried to implement somewhat logical physics, no matter how simple, but I obviously did something wrong. Despite seemingly making it so that the character goes up 7 pixels (4 + 2 + 1 + 0) and then down 7 blocks (0 - 1 - 2 - 4), they just fall straight down, off the screen. Here's my jumping code:
And this is how it's called:
And yeah, that's not optimized at all. Hahaha
Code: [Select]
Lbl JMP
Y+A>A
If A^2=0
A/2>A
End
If A=1 or A=0 or A=-1
A--
End
If A=-2
A-2>A
End
If A=-4
4>A
End
And this is how it's called:
Code: [Select]
Repeat getKey(15)
//blah blah game loop
If getKey(54) or (A!=4)
sub(JMP)
End
//blah blah blah
End //game loop ends
And yeah, that's not optimized at all. Hahaha