Introduction to Health and Melee Combat

Get a brief introduction to what you will learn in this chapter.

We'll cover the following

The brave protagonist rounds a corner in the dungeon and spots a vile goblin. Charging forward, they exchange blows with the creature until they emerge victorious. The adventurer is suddenly conscious of their wounds and stumbles back into the corridor to rest, hoping that the other goblin won’t find them.

This scene is typical of fantasy novels and roleplaying games like Dungeons & Dragons. Recreating this scene in the game requires several elements. The hero can move and fight the goblin. The goblin can fight back. The hero is conscious of their status and realizes that they need healing. They heal by hiding in a corner and waiting.

What will we learn?

In the previous chapter, we made the monsters move randomly. This chapter focuses on making the introductory scene a reality in our game. We’ll add hit points to entities, both the monsters and the player.

We’ll also introduce a heads-up display to show the player’s health and tooltips to show the monsters’ names and health. Moving into a monster will attack it, reducing the monster’s health and slaying them if their health reaches zero; likewise, monsters who move into the adventurer will damage them. Finally, we’ll add the ability for the player to heal by waiting to enable more strategic play.

Let’s get started.

Get hands-on with 1200+ tech skills courses.