Ice Wizard and Collision Events

We have defined our FireWizard and IceWizard is almost areplicate of the FireWizard. Try Completing all the events and actions for the IceWizard by yourself. Go back and forth between what you have written and keep cross-checking by playing a preview of the game. The differences of actions between the two wizards is subtle, try figuring them out yourself, you will learn a lot this way. The events for IceWizard should look like this:

Collisions

We shall now define what happens to the health of the two wizards when they get by the opponent's projectile.

  • Create a new group
  • Rename to “ Collisions / Death ”
  • Create a Sub-event under this group.
  • For condition look for “ Common actions for all objects / Collsions ”.
  • First object will be “FireWizard”.
  • Second object will be “IceProjectile”.

It should look like this:

  • Add another condition.
  • Look for “ Common conditions / Variables / Value of an object;s variable ”.
  • Set Object = FireWizard
  • Set Variable = Health
  • Set Sign = ≥ (greater or equal to).
  • Set Value = 0.
  • Add action for this event.
  • Look for “ Common conditions / Variable / Modify variable of an object ”.
  • Set Object = FireWizard.
  • Set Variable = Health.
  • Set Modification as (-) Subtract.
  • Set Value = 10.
  • Add another action for this event
  • Look for “ Common conditions / Objects / Delete an object ”.
  • Set Object = IceProjectile.

It should look like this:

You should have a fair idea about what the event should look like for IceWizard colliding with FireProjectile. Take a step forward and try completing it yourself. Compare below:

We shall now define the conditions for Death for either of the wizards.

  • Create a sub-event under the Collisions group.
  • Add a new condition
  • Look for “ Common conditions / Variables / Value of an object's variable .
  • Set Object as FireWizard and Variable as Health.
  • Set Modification as ” < “ and value as ” 0 “.
  • Click Apply, and add Action.
  • Look for ” Sprite / Animations and images / Change animation(by name) “.
  • Set Object = FireWizard.
  • Set Animation = ” Dead “.
  • Create another action.
  • Look for ” Common conditions / Variables / Value of a scene variable “.

Use this symbol to add a new variable:

  • Set a new variable as ” gameRunning “. This variable is to denote when a game ends or is running.

  • Set Modification to =
  • Set Value = 0 (To denote that the game has ended).

  • Create another action.
  • Look for ” Common conditions / Variables / Value of a scene variable “.
  • Create another new variable named as ” Winner “. But this time, it will be a String Variable.

It should look like this now:

We are done with the conditions for death for FireWizard, we need to do the same for the IceWizard, it should look like this:

You will notice now that both wizards will die once their health falls below 0. Our game is almost done, just a few more finishing touches and it's ready!

→Read the next part of the tutorial here!