Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Week 8 Update

This week was all about rewriting my code (it reminds me of this song by Dylan Beattie ). While working on Travel Puzzle Gallery, I had a hard time not getting lost in my own code, and that was for such a small game. So, I started learning about object-oriented programming to structure my code better. I think I rewrote about 90% of it.

One new thing I like is using interfaces. I created a simple one for room elements:

public interface IRoom
{
    void OnSelect();
    void OnDeselect();
    void OnHoverEnter();
    void OnHoverExit();    
}

Now, in my raycaster, I just call the appropriate method of the hit object instead of emitting an event and making all rooms listen and react. Inside the Room class, I have only those methods that change the room's appearance, making it a nice single-responsibility class.

I split the rest of my code in a similar way. It probably still needs improvements, but it is much easier to navigate through the code now. In addition to the raycaster, event manager, and room class, I have:

  • A class that stores game data/status - it keeps track of time and configures which mini-game should open from a trigger click.
  • A class for the main scene that handles the visibility of the main scene.
  • A class for triggers that handles their appearance and emits the clicked trigger name.
  • A class that handles dispatching mini-games.
  • Classes for each mini-game.

I still think there's room for improvement, so I'll probably continue polishing it while finalizing the main loop implementation (I’m about halfway there, I think).

I also decided that each mini-game will be another scene. This way, it will be easy for each game to have its own UI. I’m not sure if this is the best idea, but since I’m decoupling the code so much, it should be easy to change my mind later on.

Here's a little demo of how it looks right now:


Plan for next week: Finish the main loop logic and transfer the sliding puzzle logic into the main game. If I have enough time, I'll code the storytelling part – a feature similar to the mini-game but just a “slideshow” telling the story.

Thanks for reading!!