The HUD can be described as the graphical interface for displaying the game information such as life stat, player score, and so on.
Here we'll simply create a "Start Game" and "Quit Game" button with text, but before we do that we have to set up game states— a type of state machine that tells the various modes of a game whether the game is at the menu mode or is currently playing (game-play mode).
In the love.load()
function, set a game state as menu, so whenever the game loads its first state is the menu.
function love.load() gamestate = "menu" love.graphics.setBackgroundColor(225, 153, 0) -- load the level and bind the variable map LoadTileMap("tilemap.tmx") end
Next, we are setting another gamestate
condition; game should update and draw only when game state is "playing"
:
--Update them function love.update(dt) if gamestate == "playing" then bump.collide() PlayerMovement(dt) EnemyUpdate(dt) CoinUpdate(dt) DiamondUpdate(dt) LifeUpdate...