A downloadable book

Download NowName your own price

How to implement Thwomp in Super Mario

1. Calculates the player's distance relative to itself. Play the idle animation initially.

2. If the target is getting closer, it's animation will be switched to ready.

3. If the target is very close to the thwomp, it will fall downwards towards the target.

Also switch to falling animation. To detect the ground, just check for a collision on the y-axis.

4. It goes back up to its starting position after X amount of seconds (maybe 1 or 2, choose whatever feels right to you). As it is going back up, switch animation to idle.

Details of implementation:

How to make thwomp fall downwards:

set its gravityFactor to 40

How to make thwomp go up:

set its gravityFactor to -40

Default gravityFactor is -40, and the ceiling is holding the thwomps to stop it moving upwards.

State change:

prepare -> fall ->  far

Note that  when Skeleton Koopa revive and move on, thwomp will not enter this prepare state, but directly enter far state, this is because this.prep is true

Full code is attached.

Download

Download NowName your own price

Click download now to get access to the following files:

thwomp.js 3.1 kB

Leave a comment

Log in with itch.io to leave a comment.