Ghost enemy - TypeDefinition/NautiBuoy GitHub Wiki

The ghost:

  • Able to go through walls and will chase the player
  • Activates once player is in the same screen/scroll as it

States:

  • Rest state
  • Wake up state
  • Chase state
  • Order:
    • Rest -> (player on same screen/panel for a short period of time) -> wake up -> after a few frames -> chase state

Rest state

  • Will check if the player is on the same screen/scroll as it (within the screen resolution)
  • If player is on the same screen, it will go to wake up state
  • If player not on same screen, will just keep checking
  • Because of this, the player will technically never be able to see its 'rest state', thus, no need for resting sprite animation.

Wake up state

  • Will run a 'counter' of sorts, once it reaches a certain number, it will go into chase state
  • Has a wake up animation as a warning to the player it'll start chasing soon

Chase state

  • Starts chasing the player
  • Able to go through walls
  • Will not stop chasing until it's either dead or the player has died
  • If player has died, it will return back to its original position on the map and go back to rest state
  • Has a sort of chasing animation