Health Bar and Corner Cases

Our game is almost complete, and a little work is left.

  • Create a new group called “ Initialization ”.
  • Add a sub-event below this group.
  • Add a new condition.
  • Look for “ Scene / Beginning of the Scene ”.

  • Add an action to this event.
  • Initialize our variables gameRunning and string-variable Winner to 1 and “” respectively.

The Objects TopDelimit and BottomDelimit do not serve any purpose on the front-end and hence they must be hidden from the user. Go ahead and do that.

  • Add a new action
  • Look for “ Common actions / Visibilty / Hide an object ”.
  • Set Object = TopDelimit.

Do the same for BottomDelimit, as we did above, it should look like this:

Now we set the health bars of our wizards! Our Health bars should mimic the Health variable of our object. Or in other words, they should scale according to them.

  • Add a new sub-event
  • Do not add a condition (This means that this action will happen unconditionally).
  • Look for “ Sprite / Size / Scale on X axis ”.
  • Set Object = FireHealth.
  • Set Modfication as =(set to).
  • Set Value = IceWizard.Variable(Health) /20. (Otherwise the HealthBar will scale out of bonds for the window screen).

Similarly, complete the health bar for IceWizard. It should look like this: Now we shall limit our wizard in a certain movement area only. The hidden delimiters are going to help us in this case.

  • Add another sub-event under the group Initialization.
  • Add a new condition.
  • Look for “ Common conditions / Collision / Collision ”.
  • Set Object = FireWizard.
  • Set Object = TopDelimit.
  • Click Apply, and move over to the action.
  • Look for “ Common actions / Position / Seperate two objects ”.
  • Set Object = FireWizard.
  • Set Object = TopDelimit.

This action must be done 3 more times. For the Bottom Delimit, and also for the IceWizard and its Delimiters. This means that there will be 4 different events to specify all of these events. Try doing this yourself, and compare below:

This is what our initialization group will look like. Try playing the game now. Everything is complete, all we need to do now is present the user with the game over screen and we are done!

→Read the next part of the tutorial here!