## The perfect fall/jump

The place for codemasters or beginners to talk about programming any language for the Spectrum.
redballoon
Microbot
Posts: 120
Joined: Sun Nov 12, 2017 3:54 pm

### Re: The perfect fall/jump

R-Tape wrote:
Sun Jun 09, 2019 7:36 pm
Nice. I guess the exaggeration and base over apex jumps demonstrate that one should forget theory and go with whatever looks good!
Bingo! And I recommend this book, which is what I use. I've got it sitting out next to me for reference when I need it while doing Melkhior's Mansion animation.

Course, you may only have 4 frames...or 2 or 8, but if you're going to be doing any motion graphics, then, really, it certainly doesn't hurt knowing this. There is a PDF of the above book available if you do a Google search for it.
0 x

Morkin
Manic Miner
Posts: 626
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

### Re: The perfect fall/jump

R-Tape wrote:
Sun Jun 09, 2019 8:25 pm
And the less said about cyan the better

That's going to give me nightmares.
1 x

hikoki
Manic Miner
Posts: 400
Joined: Thu Nov 16, 2017 10:54 am

### Re: The perfect fall/jump

mcleod_ideafix wrote: After refreshing my physics here:
http://www.sc.ehu.es/sbweb/fisica/dinam ... tucion.htm

I've came up with this:

Which shows this:

In the listing:

Code: Select all

``````hmax : initial height of the particle. Set to 175 (maximum height in pixels)
vxo : X component of velocity vector. The more you put here, the farther
the particle will get to the right.
vyo : Y component of velocity vector. Initially set to 0.
e : coefficient of restitution after a colission with the ground.
g : 9.8 m/s^2
x,y : particle position in each time slice.
t : time. It's reset to 0 after each colission, as the colission marks
the beginning of a new parabolic trajectory.
``````
Post at WoS: https://www.worldofspectrum.org/forums/ ... ent_639936
1 x

djnzx48
Manic Miner
Posts: 553
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

### Re: The perfect fall/jump

Code: Select all

`````` 1 LET g=-0.025: REM gravity
2 LET b=-0.8: REM bounce factor
5 LET vx=0.5: LET vy=0: REM velocity
10 LET x=0: LET y=175: REM displacement
20 PLOT x,y
30 LET vy=vy+g
40 LET x=x+vx: LET y=y+vy
50 IF y<0 THEN LET y=0: LET vy=vy*b
60 IF x<=255 THEN GO TO 20``````
1 x

RMartins
Manic Miner
Posts: 392
Joined: Thu Nov 16, 2017 3:26 pm

### Re: The perfect fall/jump

R-Tape wrote:
Sun Jun 09, 2019 7:36 pm
Einar Saukas wrote:
Sun Jun 09, 2019 2:38 am
The main reason it doesn't look right, is that the ball suddenly stopped moving forward while falling.
My picture is misleading—it allows horizontal movement during fall and I just stopped pressing the key.
To feel smooth, user input needs to control acceleration, not velocity or position (X in this case).

If each time you stop pressing the key, you stop any movement in X axis, it will not feel smooth.

NOTE: You also need some kind of attrition force, to make the object stop, after you stop accelerating.
I use a percentage of the - velocity or a fixed amount with opposite sign to velocity (abs equal or lower to actual velocity) so that when it reaches near zero, it will become zero).

In Steel Ball I implemented a 24 bit fixed value for X and 16 bit fixed value for Y, so that movement was smooth.