Blog

  • Code-Centric Game Engines

    I have playing with Godot on and off for a while. Recently, decided to try the First 2D Game tutorial. Code-wise it was easy to follow, but there is too much interaction with GUI and if you miss-click, it is really hard to debug it.

    As a programmer, I prefer text over GUI, I wondered if there are any text or code centric game engines. After some web search and AI discussions, here are some promising code-centric game engines frameworks.

    LOVE/Love2d

    This is the oldest, stable, open source, with largest community text-based game engine. It has no builtin text editor, so you are free to use any you like. It lacks some stuff like physics. But since it has been around for a long time, it has a lot of libraries that provide missing functionalities.

    It uses Lua language which is a popular language in modding community.

    It also seems to get a lot of love on HackerNews.

    DragonRuby

    DragonRuby is a closed-source, commercial game engine. It is another code-centric engine with no GUI. I really like that it uses Ruby since I use same at the work. It can also publish your games on Steam, App & Play stores, even supports Oculus Quest.

    Bevy

    Bevy is the youngest, open source, capable of both 2D and 3D games, text-based engine. It uses Rust, that is an exciting language.

    It is still in 0.x.x version, so it maybe not as stable. Smaller community as well.

  • Godot: Error in 2d tutorial

    During the HUD step of the 2D tutorial, I encountered the following errors:

    E 0:00:06:0368   main.gd:58 @ _on_score_timer_timeout(): Node not found: "HUD" (relative to "/root/Main").
      <C++ Error>    Method/function failed. Returning: nullptr
      <C++ Source>   scene/main/node.cpp:1793 @ get_node()
      <Stack Trace>  main.gd:58 @ _on_score_timer_timeout()
    

    and

    E 0:00:07:0214   main.gd:19 @ game_over(): Node not found: "HUD" (relative to "/root/Main").
      <C++ Error>    Method/function failed. Returning: nullptr
      <C++ Source>   scene/main/node.cpp:1793 @ get_node()
      <Stack Trace>  main.gd:19 @ game_over()
                     player.gd:48 @ _on_body_entered()
    

    The Issue

    The problem was that I had accidentally added the HUD scene to the “mobs” group. In my new_game() function, I had this code:

    func new_game():
        print("in new_game")
        score = 0
        $Player.start($StartPosition.position)
        $StartTimer.start()
        $HUD.update_score(score)
        get_tree().call_group("mobs", "queue_free")
        $HUD.show_message("Get Ready")
        print("HUD is still set: ", $HUD)
    

    The call to get_tree().call_group("mobs", "queue_free") was intended to free all mob nodes. However, because the HUD was mistakenly a member of the “mobs” group, it was queued for deletion. Godot uses deferred deletion, meaning that nodes marked with queue_free() are not immediately removed but are deleted at the end of the current frame. This is why the HUD reference appeared valid immediately after the call, but was null by the next frame when accessed again.

    Debugging the Issue

    I added debug prints such as print($HUD) and even checked the groups with get_groups() on the HUD node. The outputs confirmed that the HUD was indeed part of the “mobs” group. Additionally, placing a print in the HUD’s _exit_tree() method would reveal when the node was being freed, which can be invaluable in tracking down such issues.

    Best Practices to Avoid Similar Issues

    • Group Management:
      Always ensure that UI elements, like the HUD, are kept in separate groups from gameplay elements. This prevents accidental deallocation when freeing nodes from a group.
    • Verify Group Membership:
      Use the Godot editor or code ($HUD.get_groups()) to check which groups a node belongs to. If needed, remove a node from a group with $HUD.remove_from_group("mobs").
    • Deferred Deletion Awareness:
      Understand that queue_free() does not remove a node immediately. This deferred deletion can cause references to seem valid momentarily even after being marked for deletion.

    The Resolution

    Removing the HUD scene from the “mobs” group fixed the issue. This experience highlighted the importance of carefully managing node groups and understanding deferred deletion in Godot.

  • git error: github.com:abc/xyz.git did not send all necessary objects

    I was getting following error when running git pull

    git pull
    fatal: bad object refs/heads/master 2
    error: github.com:abc/xyz.git did not send all necessary objects
    

    I tried running git gc

    git gc
    error: bad ref for .git/logs/HEAD 2
    fatal: bad object refs/heads/master 2
    fatal: failed to run repack
    

    The fix was to remove above to files under .git

    rm .git/logs/HEAD\ 2
    rm .git/refs/heads/master\ 2
    

    After that I was able to run gc and do git pull

    git gc
    Enumerating objects: 257, done.
    Counting objects: 100% (257/257), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (224/224), done.
    Writing objects: 100% (257/257), done.
    Total 257 (delta 85), reused 0 (delta 0), pack-reused 0
  • 10 Inspiring Photographers

    Recently, I have watching Steve Carty’s videos on YouTube and learning a lot from him. One of his recommendations is to make a list of 10 photographers who you want to imitate, who are more advanced than you.

    I have been following many photographers on Instagram, but without any focus. Since I want to specialize in underwater photography, I decided to create this list.

    Elizabeth Blank (website)

    Learned about her from a podcast interview. Her portfolio is exactly what I want to do, underwater portraits and commercial photography. It seems she has been active lately, but her site is still a great inspiration.

    Adam Opris (website)

    While not strictly underwater photographer, I really like that his photography is mix of underwater and on land. I also don’t want to be only underwater photographer. While I would never do weddings, but would love creative and artistic photos on land.

    Brandon Woelfel (Website)

    Not an underwater photographer but I really love his photos.

    Steve Carty (website)

    He is a great teacher, and I love his portraits.

    Kasey Vaitekunas/One Sweet World Images (website)

    Kasey also does both underwater and on land photography. Love her portfolio as well.

    Flash Pool Productions (website)

    Sarah (the owner) seems to be strictly underwater photographers. Really like her portfolio as well.

    Sarah Hoover (website)

    Another great photographer. She not strictly underwater photographer but love her portfolio. Her photos are dreamy, painterly. That’s the style I also want to master. Really love her Magic Photography.

  • The Carty Method

    YouTube introduced me to Steve Carty recently. I learn from a lot of YouTube photographers but Steve Carty has given me more useful information in last few days than any other ever.

    His portfolio is here https://www.stevecarty.com.

  • Hello world!

    Taking photography seriously.