Adding finishing details to the game

The game is now functionally complete, but there are a few elements left to polish up. To start, the player takes damage but never dies, nor is there a heads-up display (HUD) to show this. Let's create a quick Overlord.

  1. Create a new Object, obj_Overlord, with no sprite applied and persistence is checked.
  2. Add a Draw GUI event and a new Script for it, scr_Overlord_DrawGUI, with the following code:
    draw_healthbar(0, 0, 200, 16, health, c_black, c_red, c_green, 0, true, true);
    
    if (health <= 0)
    {
        with (obj_Player) { instance_destroy(); }
        room_goto(TitleScreen);
        instance_destroy();
    }

    First, we use the function draw_healthbar which you can see has a lot of parameters. The first four are the size and placement of a rectangular ...

Get HTML5 Game Development with GameMaker now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.