Skip to content

Instantly share code, notes, and snippets.

@lethal-guitar
Last active December 7, 2023 12:33
Show Gist options
  • Save lethal-guitar/6ca0aa69786c7ad8a2319489503850b0 to your computer and use it in GitHub Desktop.
Save lethal-guitar/6ca0aa69786c7ad8a2319489503850b0 to your computer and use it in GitHub Desktop.
Duke Nukem 1 bouncy mine
/*
Lookup table
The numbers are in 1/8th of a pixel.
See https://lethalguitar.wordpress.com/2023/11/12/duke-nukem-1s-sprite-rendering/#coordinate-systems
*/
int BOUNCE_MINE_JUMP_ARC[] =
{128, 96, 64, 32, 8, 4, 1, -1, -4, -8, -32, -64, -96, -128};
/*
Bouncing logic
Runs once every frame for each bouncy mine actor
actor->state is initially -6
*/
actor->y -= BOUNCE_MINE_JUMP_ARC[actor->state + 6];
actor->state++;
if (actor->state == 8)
{
actor->state = -6;
}
if (actor->state == -6)
{
PlaySound(SND_MINE_BOUNCE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment