How To

How to add a jump animation

3

nebyoolae 2023-09-12 22:00 (Edited)

I'm working on an ice skating game, and I have my basic "move in 2D" update method working (with acceleration and deceleration, even!).

However, I'd like to implement a jump move when you press a button. I know I need to trigger something like this:

IF BUTTON TAP(0,0) THEN
  'GO UP
  Y0=Y0-1
  SPRITE SPR_SKATER,X0,Y0,
  WAIT 1

  ...

  'GO DOWN

  WAIT 1
  Y0=Y0+1
  SPRITE SPR_SKATER,X0,Y0,
END IF

This won't work because it pauses the whole game, but it's the general gist. How do I actually do this?

Nebyooskate.nx | Open in app
2023-09-12 22:00

nathanielbabiak 2023-09-13 00:36 (Edited)

Mario Run

What is the best way to make a platformer?


nathanielbabiak 2023-09-13 00:45 (Edited)

Here's the one I was looking for...

'Mario style' jumping


nathanielbabiak 2023-09-13 00:56

Hey so those other posts are definitely a good... jumping off point.

But, the major issue in the code snip you posted is that you need to change your viewpoint a bit. You need to track "status" of the jump (and player position, and collisions, etc) as shown in the links I posted.

But, at the same time, you need to allow the program's main loop to cycle through with only a single WAIT VBL inside. Basically every time the loop executes needs to be structured, logically, as a "physics" "slice in time" of 1/60 of a second. Your code doesn't do that.


was8bit 2023-09-13 03:01 (Edited)

Check out my code for game#3 in arcade word games...

I have 2 clown icons, and there are 4 different modes of how each clown will behave based upon their circumstance... and they are all time controlled with one WAIT VBL... and any counters I use I assume then that each counter will advance every 1/60sec or one WAIT VBL...

All movement moves at one WAIT VBL or 1/60sec... and I use counters to slow down some movements .. for animations here is a good slowdown fine tune code...

Add iwait,1,0 to number
If iwait=0 then doanimation

Adjust number till your animation looks right :)


nebyoolae 2023-09-13 15:41

Thanks for the replies! My implementation is lame and naive, but it actually does work in a terrible way. That being said, I will reimplement using that 'Mario style' method you linked, because that seems awesome.


nebyoolae 2023-09-13 15:41

Just realizing that my avatar has both a potential forward AND upward velocity was a key idea I hadn't thought about before.


Best Broz 2023-12-16 13:07 (Edited)

It doesn't work for me but thanks anyway 👍👍😃


Log in to reply.