Condition

From Castle Wiki
Revision as of 15:54, 13 May 2022 by Ben (talk | contribs) (Created page with "A '''Condition''' is a type of Response which only runs its enclosed logic when a certain condition is true. For example, imagine an adventure game where the player needs...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A Condition is a type of Response which only runs its enclosed logic when a certain condition is true.

For example, imagine an adventure game where the player needs to use a pick to mine gold. When the player touches a piece of gold, you need to check if they have the pick to decide what to do. You might write a rule like this:

When this collides with tag #gold:
  If variable $has_axe equals 1:
    Tell the colliding actor: Destroy this actor
    Set variable $num_gold to 1 (Relative)
  Else:
    Create text box "You need the axe to get the gold"

List of conditions

State

Collision

  • If this is colliding

Random

  • If a coin flip shows heads

Camera

  • If this is in the camera viewport

Draw

  • If the animation frame meets a condition