GameMaker Programming a thwomp-like enemy?

conman06

Member
Hey, just wondering if anyone has scripts for a thwomp or if anyone know how to program a thwomp. If you could share it with me I would greatly appreciate it. Thanks!
 

conman06

Member
I've been stuck for these past few days, thinking about what I could do, but all of them won't work.
 

Yal

🐧 *penguin noises*
GMC Elder
Make a state machine with four states: "look for player", "fall down", "sit on ground for a while", "slowly move up".
  • The "look for player" state switches to the "fall down" state if the player is below the thwomp and close enough on the x axis.
  • In the "fall down" state the object increases its vertical speed every step; if it hits ground, it switches to the "sit on ground for a while" state. (and stops moving down)
  • In the "sit on ground" state, the object decreases a counter variable (which was set before the state transition). When zero, it switches to the "slowly move up" state.
  • In the "slowly move up" state, the object moves up at a set speed. When it reaches its ystart position, it switches back to the "look for player" state.
Easiest way to make a state machine is having a variable state, and a switch statement in the object's step event.
 

Yal

🐧 *penguin noises*
GMC Elder
Perhaps if you could explain to us less-knowledgeable people what a "thwomp" is? What are you wanting this thing to do?
One of the iconic recurring Mario enemies, a sentient block of stone that attacks by slamming into you with the force of gravity and then takes a very long time to get back into position again.

1593812336903.png
 
One of the iconic recurring Mario enemies, a sentient block of stone that attacks by slamming into you with the force of gravity and then takes a very long time to get back into position again.
Ah, never played any Mario game so did not know this. Thanks for clearing that up.
 

TheouAegis

Member
I'll elucidate on some things Yal said - which is the correct way to make a Thwomp.

First off, set the origin of the Thwomp sprite in the horizontal middle. You can use middle-center, middle-top, or middle-bottom, either will work the same.

"if the player is below the thwomp..."
if player.y > y, or if player.bbox_top > bbox_bottom

"... and close enough on the x axis"
if abs(player.x - x) < 8

"its ystart position"
The variables xstart and ystart are automatically created by all instances (I think before the Create event) and typically are used to keep track of where the instance was first created.

If your thwomp is going to rise at a speed that is not an integer, you will want to check if y <= ystart and then set y to ystart before going back to the waiting state.
 

conman06

Member
Make a state machine with four states: "look for player", "fall down", "sit on ground for a while", "slowly move up".
  • The "look for player" state switches to the "fall down" state if the player is below the thwomp and close enough on the x axis.
  • In the "fall down" state the object increases its vertical speed every step; if it hits ground, it switches to the "sit on ground for a while" state. (and stops moving down)
  • In the "sit on ground" state, the object decreases a counter variable (which was set before the state transition). When zero, it switches to the "slowly move up" state.
  • In the "slowly move up" state, the object moves up at a set speed. When it reaches its ystart position, it switches back to the "look for player" state.
Easiest way to make a state machine is having a variable state, and a switch statement in the object's step event.
Thank you!
 
Top