Coding a level select menu in Godot


Coding a level select menu

(This is a copy of a post from my main devblog on tumblr: https://roboticastudios.tumblr.com)

I want to preface that I am not the best at anything, especially programming, but I thought I would share how I handle level select menus in TeTriDi, where I have menu screens that let you select between 20 different levels. Hopefully these kinds of posts are helpful to other indie devs out there, and still interesting for the non-indie-devs as well! And if you have improvements to share, I'm all ears, I'm still learning!

Here is a screenshot of what the menu looks like:


TeTriDi is made in the Godot Engine v3.5, with which I use GDScript.


First of all, the setup variables. I prefer creating onready vars for direct node access, this is handy in case you later change the node tree structure, all you would have to do is update these parameters at the top of the code.


In Godot, the _ready() function is run during initialization of the script, so in this case I use it to initiate the UI focus grabbing onto the first button, which represents the first level, and to call for displaying the current record of that level.

The for loop here is for connecting all of the buttons pressed signals via code instead of through the nodes GUI settings, this is important for the way I'm doing this menu.


Under the _process function, which runs constantly, I set the selector position to the button that currently has focus, with a position offset to make the selector sprite align properly. This does require that you set the focus options on the button nodes focus properties.

On each button pressed I have set the transition type and new scene directory before beginning the transition.

Under _unhandled_input I have the cursor move sound effect and current_record functions so that they run anytime the player hits the any buttons.


The current_record function gets the level number, score, and text from my global script.

And that's it! If you have any questions or feedback feel free to comment or reach out. Thanks for reading.

If you'd like to keep up with my projects, you can bookmark www.roboticastudios.com

Get TeTriDi

Buy Now$3.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.