1. Star Child
  2. News
  3. Star Child Dev Log #37

Star Child Dev Log #37

Jay Ingle - lead developer, designer, and artist:

This week I've been doing menu and UI work. This is my least favorite part of game development, however I have found some satisfaction from solving some coding problems.

Recently, I have improved my coding. I have been using dictionaries and For loops to set properties as needed. The catalyst for this was the realization that I can populate a dictionary with references to nodes, and iterate thru them as needed. It got even better when I learned that I can use scene-unique names (denoted by the %) in my menus, so that if I rearrange the containers, nothing is broken, and I don't have fix broken references.

@onready var menus = {
"Options": %CenterMain,
"Audio": %CenterAudio,
"Video": %CenterVideo,
"Keyboard": %CenterKeyboard,
"Controller": %CenterController,
}


So if I wanted to hide all of these menu nodes, I could do:

func hide_menus():
for menu in menus:
menus[menu].visible = false


In the past, I would have set onready vars for every menu, which would have to be redone if I changed the node structure of the containers.

@onready var options_menu = $OptionsMenu
@onready var audio_menu = $AudioMenu
...etc


Then I would have done this mess:

func hide_menus():
options_menu.visible = false
audio_menu.visible = false
video_menu.visible = false
keyboard_menu.visible = false
controller_menu.visible = false


This is bad, obviously. It wastes so much time, and is highly prone to bugs/typos. It is quite a relief to understand how to write decent code using data structures.

And I must thank my teacher, ChatGPT. Oh no! Are we letting AI write code for Star Child? No. But in absence of an actual human teacher, AI has been extremely helpful to me, in learning how to write better code. Conclusion: AI is great for learning, if you approach it like you are actually trying to learn and be independent, rather than trying to let AI do your homework for you.

I, for one, will never accept our robot overlords. However, thank you, robot, for helping me be a better game developer.

One month and six days until the Star Child demo will be out, in time for Steam Next Fest! I better get back to work.