5 lessons from my first Godot project, inspired by Stardew Valley

I have zero experience in game dev, but I’m learning to build small games as a hobby. Today I finished a project to learn more about the Godot game engine. This quick note sums up what I learned & the things that I found challenging.

My project is inspired by the progress tracking screen in Stardew Valley:

When the player goes to sleep in Stardew Valley, they earn gold for activities such as fishing and farming:

My game has a similar — albeit less polished — aesthetic, but the activities are based on your real-life new year’s resolutions. It’s really more of a little app than a game:

What I learned

  • 1: How do I let players save their games?

    • A: Place the nodes that should be saveable into a group called “Persist.” The nodes in “Persist” must implement a “serialize” method that translates their properties to JSON, then save the JSON to a local file.

  • 2: How do I let players load their saved games?

    • A: The nodes in the “Persist” group must also implement a “deserialize” method. It instantiates a game node and assigns properties from the JSON file described above.

  • 3: How do I collect input from the player?

    • A: Use LineEdit, HorizontalScroll, and Button components nested within a “Control” wrapper.

  • 4: How do I manage state shared by many nodes?

    • A: I used Godot’s “autoloading” feature to load a singleton class that contained utilities for determining the current season, information that many nodes need when the game starts.

  • 5: How do I manage styles and layouts?

    • A: Use themes and theme overrides to set custom styles. Use Horizontal Box and Vertical Box containers along with the “Control” component to flexibly lay out UI elements.

Challenges

  1. I ran into several runtime errors due to GDScript’s dynamic typing. For future projects, I might use C# for type safety, but I’ve also heard that C# presents some compatibility issues. 🤷‍♂️

  2. The layout rules for nested components were a bit complex. They reminded me learning flexbox back in the day.

  3. Saving/loading games required more boilerplate than I expected. I read that there’s a faster alternative, but it carries significant security risks (arbitrary code execution).

Bottomline

Overall, I had a blast building this basic little project in Godot. I learned how to collect user input, create themed menu layouts, and implement basic scene transitions. I ran into a few hiccups related to GDScript’s dynamic typing, the complexity of nested layouts, and the tediousness of saving state, but I think it’ll get easier as I pick up more experience using the engine.

P.S. This just-for-learning project includes borrowed artwork from Stardew Valley. I have no intention to publish, sell or distribute it.

Previous
Previous

PNW winter wonderland

Next
Next

A snowy adventure in Canada unlocks Fog of World Lvl. 100