Finishing up
We have now completed all the functionality for our game. Below are some remaining steps to add a bit more “juice” to improve the game experience. Feel free to expand the gameplay with your own ideas.
Background
ColorRect node. Make it the first node under Main so that it will be drawn behind the other nodes. ColorRect only has one property: Color. Choose a color you like and select “Layout” -> “Full Rect” so that it covers the screen.
TextureRect node instead.
Sound effects
Sound and music can be the single most effective way to add appeal to the game experience. In your game assets folder, you have two sound files: “House In a Forest Loop.ogg” for background music, and “gameover.wav” for when the player loses.
AudioStreamPlayer nodes as children of Main. Name one of them Music and the other DeathSound. On each one, click on the Stream property, select “Load”, and choose the corresponding audio file.
$Music.play() in the new_game() function and $Music.stop() in the game_over() function.
$DeathSound.play() in the game_over() function.
Keyboard shortcut
Button node.
In a previous lesson, we created four input actions to move the character. We will create a similar input action to map to the start button.
start_game and add a key mapping for the Enter key.
HUD scene, select the StartButton and find its Shortcut property in the Inspector. Select “New Shortcut” and click on the “Shortcut” item. A second Shortcut property will appear. Select “New InputEventAction” and click the new “InputEventAction”. Finally, in the Action property, type the name start_game.
Now when the start button appears, you can either click it or press Enter to start the game.
And with that, you completed your first 2D game in Godot.
You got to make a player-controlled character, enemies that spawn randomly around the game board, count the score, implement a game over and replay, user interface, sounds, and more. Congratulations!
There’s still much to learn, but you can take a moment to appreciate what you achieved.
Your first 3D game to learn to create a complete 3D game from scratch, in Godot.
