How to Make a Strategy Game in Godot - Part 2

How to Make a Strategy Game in Godot – Part 2


Welcome back to Part 2 of creating a strategy game in the Godot game engine!

In Part 1, we began showing you how to build your first strategy game in Godot by setting up highlight-able tiles, buildings, and the basic UI which will tell the players crucial information about their resource management.  All in all, we have a great foundation to work with so we can finish our project and add it to our portfolio!

Of course, with this being Part 2, there is still more go.  We need to finish up our map system, set up our UI properly, give ourselves the ability to place buildings, and even implement the overall turn-based gameplay flow.  So, if you’re prepared, and let’s finish this resource management game and become master Godot developers!

Project Files

In this tutorial, we’ll be using some sprites from the website (an open domain game asset website) and fonts from Google Fonts. You can of course choose to use your own assets, but we’ll be designing the game around these:

  • Download the sprite and font assets we’ll be using for this tutorial here.
  • Download the complete strategy game Godot project here.
Don't miss out! Offer ends in
  • Access all 200+ courses
  • New courses added monthly
  • Cancel anytime
  • Certificates of completion

Finishing the Map Script

To begin, let’s go back to our Map script. The place_building function gets called when we want to place down a building on a tile.

Finally, the _ready function gets called when the node is initialized. Here, we want to get all of the tiles in the “Tiles” group and setup the initial base building.

Back in the MainScene, let’s select the center tile and enable Start Tile.

Selecting the center tile and making it the starting tile.

Now if we press play, you should see that the center tile has a Base building on it.

The start tile now displays the Base building.

GameManager Script

The GameManager script is what’s going to manage our resources and states. Go to the MainScene and select the MainScene node. Create a new script attached to it called GameManager. We can start with our variables.

The on_select_building function gets called when we press one of the three building UI buttons. This will be hooked up later on when we create the UI script.

The add_to_resource_per_turn function adds the given amount to the given resource per turn.

The place_building function will be called when we place down a tile on the grid.

Finally, we have the end_turn function which gets called when we press the end turn button.

Okay so we’ve got our GameManager class all setup but there’s no real way for it to function. In order to connect everything together, we need to create a UI script.

UI Script

In the UI scene, select the UI node and create a new script called UI. Let’s start with our variables.

First, we have the on_end_turn function. This gets called when a turn is over, so we’re going to reset the UI.

The we have the update_resource_text function which updates the two resource labels to show the player’s current resource values.

Now we need to connect the buttons. In the UI scene, do the following for the EndTurnButton, MineButton, GreenhouseButton and SolarPanelButton…

  1. Select the button node
  2. Double click the pressed signal (called when we press the button)
  3. Connect that to the UI script

Connecting the buttons to our UI script using signals.

So back in our script, we’ll have 4 new functions. Let’s start with the three building buttons.

Then we have the end turn button function.

Connecting Everything Together

Now that we have our UI script, let’s go back to the Tile script and fill in the _on_Tile_input_event function.

Next, let’s hop into the GameManager script and create the _ready function. Here, we’re going to initialize the UI.

At the end of the end_turn function, let’s also update the UI.

Finally, at the bottom of the place_building function, we can update the resource text UI.

Now we can press play and test out the game!


Congratulations on completing the tutorial!

You just created a 2D, turn-based strategy game in Godot.  Through this journey, we’ve covered a wide array of topics, from setting up objects that give and take resources, to creating a tile-based map that provides visual clues about where buildings can be placed.  Further, with turn-based gameplay mechanics also introduced, we’ve tackled a key component for many other sorts of strategy games as well!

From here, you can expand upon what you’ve learned to add more systems, work on existing ones we touched on here, or even start a new strategy game project with Godot. Regardless, thank you very much for following along with the tutorial, and we wish you the best of luck with your future Godot games.