Sunday, 19 May 2013

#6.2 Tutorial (LibGDX & MTX 2.1+) Flame Words - The Structure

First of all, this may not be the greatest game structure of all or perfect idea of game foundations. I will admit that I have unique style of my own. I worked many other game structures, MVC styles and so on. They have all pros and cons, but at the end I ended up with my own unique structure which works fine for me. In future, I will adapt to new structures, I will learn from my mistakes, all in all, I am newbie guy that graduated from university recently and tries to find a path in game programming world.

Tell me what is bad or good about the structure, what can be changed for future. I will think more on them. I will create better foundations in future. I am here to learn and experience, you will find strong ideas in my games and structures as well as weak and stupid ideas :D loll...

Before GameManager
Everything should be clear. We have screens and screen helpers. I use screen helpers to divide the tasks of menus (More cohesive approach in OOP), this gives me incredible flexibility and maintainability for my games, I can honestly make any game menu you can imagine with this approach. I do not stack all game menu elements in a screen or in a class, I divide them into objects and use effects on them.

Sub Manager of GameManager
I have around 8-9 sub managers (HintM, AchievementM, PuzzleM, PunishmentM, NotificationM, SwarmM, EffectM, TutorialM, etc...) Why so managers ? Simple, again Choseion off OOP. I have single duty for all my managers, if have a problem about hints, I look into hint manager, if I need a new feature I will make a new manager, if I need to update a manager, I know where it is. Very very very flexible and maintainable approach for future and very easy to develop the game. All these managers communicates with World and GameManager without problems.

GameIOManager, Data Objects, Database
I have very simple database (textfiles), database can be anything XML, Server, a JSON file or TextFile. I simple read and write textfiles through GameIOManager. I get data from text file and put them into DataObjects (GameData, PlayerData, PuzzleLevel). What are these data: fire level, meter level, current level, etc...

When you touch a letter or fire many things happens logically. It was the best idea create a input manager for it. So, I can easily work on it, for example you touch a letter and many things happens: play audio, run effect, update word, update guess box on top, if word finished, check game condition, update blue water meter etc...

This was a great idea, this is the EffectCenter (Static class) of the game wihich manages all the Scene2D actions. For example, runNewWordEffect, runGenerealButtonEffect, runNewHintEffect, runToggleButtonEffect, runMenuEffect, etc... For any effect, I know where to look and I know what to change. This is also good to prevent code duplications, for example button effects managed from a single place.

I have single android object that comes from android (MainActivity) and this the king of classes. It has many sub interfaces and it can be added many other interfaces. At the moment it has IAdController which controls advertisements and IAndroidIntents which start intents.

This was an experimental game, more oop and database management needed in future. For example, factory classes could be good or xml/json as database management could be great. I will think more on those in future


  1. Awesome Blog. Thanks. Do keep posting such good blogs. Thanks for sharing Informative posts.
    Android Application Developer India & Android Application Development Company

  2. Awesome the way can u place a high resolutions image? thank u!