This is an example of one way to program a variable 'lives' with game characters. If the pink ghost touches the blue dragon then the dragon loses a life. Use arrow keys to move the blue dragon. Note the ghost has no coding to make it move. No maze background has been added yet.
Sprites from Flaticon.com