I like most things I see about Godot, and I’m going to try making some games with it.

Whenever I imagine programming a game though, I imagine the game logic and simulation being separate from the display. For instance, if I was to make a game like FTL, I would plan to simulate all the ship interactions and the movement of the characters purely in code, and then write a separate module to render that simulation. The simulation could be rendered with graphics, or with text, or whatever (of course, a text render wouldn’t be human friendly, but could act as a dedicated server for some games, or I could use it for machine learning, etc).

I’m not an expert at Godot, but it seems this mindset is not going to fit well into Godot. Is this correct? It seems like the same object that is responsible for tracking the players health is going to also be responsible for drawing that player on the screen and tracking their location on the screen, etc. Will my player class have to end up being a subclass of some complicated Godot class? (Also, I’m a fan of functional programming and don’t always use a lot of classes if given the choice.)

What are your thoughts about this. Would you recommend another engine? No other engine seem to be in the same sweet spot that Godot is currently in.

  • fsk@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    This solution is “ugly” from a programming theory perspective, but it works, especially for a single-player game. You have a global Singleton class that has all the game state information. In the GUI part, you have it check the global Singleton when deciding that to draw.

    If you do it this way, you can put the game logic in another thread, or even use a C/C++ GDExtension if you want really high performance.

    For example, you keep the player’s HP in a global singleton. Then in the GUI where you show the player’s HP, you have it check the value in the global singleton.