Using a little inertia with sprite movement

Have you seen a game that uses a bit of inertia with a sprite when a button is pressed? Hmm or maybe when the button is released is the proper thing? Anyway, imagine space invaders where you press left and after you release the button, your cannon takes a moment to slowly come to a stop. Any examples you have come across?

1 Like

You can always add a speed variable to your coordinate that decrease to 0 ( 3, 2, 1, 0) on everyframe when the button is released. That should give you that kind of effect. Unless you want to use real physics.


I do this in Midnight Wild to create a sense of arch (gravity) when he jumps.

@Vampirics so, in taking ArduBreakout as an example. I want to have the paddle have inertia when I let go of the button, and come to a slowing stop. Currently the button code is:

  //Move left
  if(xPaddle > 0)
    if (arduboy.pressed(LEFT_BUTTON))

And it moves the paddle Left in increments of -2. So I would countdown the movement amount from 2 to 0 over some number of frames?

@crait thank you.
A. I hadn’t seen Midnight Wild before, it’s great! Cowboy Castlevania, how was this not on SNES BITD?
B. My hacky coding is not up to parsing what you did, but thnaks for weighing in.