Skip to content

Game Entities

Henrique Campos edited this page Jul 20, 2017 · 2 revisions

Actors

Actors are any in-game entity that is supposed to act both by itself with some short of Artificial Intelligence or by an actual life agent, such as a Player. They differ from obstacles and artifacts, which are static objects which don't have a purpose by themselves, such as a cheese piece or a crater.

Astromouse

Description

The main character by himself should be an Actor since it is the main protagonist, but his implementation is as an object not as an agent, his attributions are:

  • Suffer interferences from the Moon's gravitational field
  • Suffer interferences from the Planet's gravitational field
  • Be dragged by the Shooting Star
  • Catch the Cheese Pieces when colliding with them
  • Die and call the lose screen when colliding with Comets or Planets

Note that are his attributes are passive, by himself he doesn't alter the state of any other object, he just checks for conditions and passively reacts to them, but just to avoid confusions in the project's folders and organization he will be treated as an actor.

Script

Astromouse has a method to make him jump. The jump() function which just takes his jump_force and applies it as an impulse. This also toggles the can_jump variable.

The gravity_battle() is used only when a gravity battle starts. It will first set the Astromouse gravity scale to 1, so that he can float, then it will apply an impulse in the direction of the object with the force of the gravity.

The finish_gravity method will just reset the gravity scale to the default one before the gravity battle event

Moon

Description

The Moon is the main object of the game as a system. The player will most often use it to achieve the game objectives. Its main attributions are:

  • Apply impulse on the Astromouse when possible (i.e. when jump is available)
  • Bring Astromouse back to its surface to avoid him fall into the void
  • Fight against Planets to keep Atromouse on its surface, this is basically the same behavior as the last one
  • Produce cheese pieces when colliding with Comets.
  • Create a crater on the collision point with a Comet.

Script

The moon main interaction is through the _astromouse_interact() method. It will verify if the is_mouse_on bool is true, and if the jump action is pressed and if wasn't already_pressed. Then it will try to find the player's object, which is the Astromouse, by using the find_player() after that it will verify which is the current game_state by using the playground.get_game_state() method. If it returns NORMAL, the Moon will call the jump() method on the player, if it returns GRAVITY_BATTLE then the Moon will call the gravity_battle(object, gravity) method of the player, passing itself and its gravity_strength as arguments.

The Moon tries to find the Astromouse object every time the player taps it. By using the find_player method, which just runs through all the Moon's parent's children verifying if any of them are inside the player group, if they are it will return them.

The mouse_enter() just toggles the is_mouse_on variable which is trigged by the mouse_enter and mouse_exit signals.

By calling the prepare_for_gravity() method the Moon will free every child inside the enemy group, cleaning up its surface so that the player is free of obstacles while battling the Planet.

Comet

The Comet is an actor who tries to collide with the Astromouse by moving towards him, the player can change its route by tapping near to it, this will reflect its route making it start to move in the opposite direction which the player tapped. If it collides with the Moon it will disappear, leaving a crater and making the Moon produce some cheese pieces. Its main attributions are:

  • Move through Astromouse's position
  • Trigger Astromouse's death condition
  • Change its movement direction when triggered (e.g. when player taps on its surface)
  • Trigger Moon's when colliding on its surface to create craters and cheese pieces

Shooting Star

The Shooting Star will be moving between the Astromouse jump's range. When instanced it will just move to the opposite side of the screen, if in the meantime the player was able to make the Astromouse collides with it, then it will let the mouse ride on it and both will follow be dragged by the player's finger. Its attributions consist on:

  • Move to the other side of the screen
  • Trigger Astromouse's riding on the star's condition
  • Follow player's input after the above trigger
  • Collect cheese pieces while following player's finger
  • Vanish after an arbitrary period of time

Planet

The Planet is the main antagonist of the Moon, it will try to take Astromouse out of Moon's gravitational field while pulling him into its. Its main attributions are:

  • Randomly appear on the screen from time to time
  • Exert a gravitational force trying to drag Astromouse to its surface
  • When succeed, trigger Astromouse's lose condition
  • Battle with the Moon for Astromouse