Dev Blog

Weekly Development & Artwork Updates

RpgLegend Update: Engine Revision

Categories: AetherStory Game Dev
Written by thephantom on Dec 18 2016

Returning to the development of RpgLegend after taking a couple of months working on the website, the story, and being occupied with other projects, I quickly realized that the RpgLegend project was a mess!

A couple weeks ago I decided to split the RpgLegend code base into an engine.  This isn't to say I am making my own engine from scratch or even starting over. This is far from it.  But I am organizing the code.  And by organizing the code I will be able to add more features more easily, more rapidly, and without the headache of trying to insert code into a mess.

At first I started this engine split as an experiment to even see if splitting it was a good idea.  I consulted with two frequent viewers of the stream (cruor99 and powerfear) on best coding practices and design patterns.   And I am pleased to announce that after working on organizing the code for the past two weeks, this was a great idea.  A fantastic idea!


Here are some reasons that have made it a great decision:


1. Game Logic Separated from Game Engine

By moving the render code, for example, out of the RpgLegend project and into a separate project titled "PhanxEngine", allows me to keep the RpgLegend simpler and more concise.

One of the down falls of the old project was I found there were several files that were over 4000 lines of code.  And let me tell you what any experienced programmer will tell you: if you find your file getting over 1000 lines of code you are probably doing something wrong: time to split it up into other classes or components.

So now I can think about game logic and reference the utilities from the game engine without having to worry about how the game engine works underneath, just rather how to interact with it.


2. Structure from Design Patterns

The old RpgLegend code base did not follow many design patterns, in fact I had multiple classes for the same objects and their functionality was split in different files.  It was a mess.  A complete mess.   This was another reason I knew I could not maintain this code base.

However! Now, with the new engine I am trying to follow some design patterns, or at the very least I have been inspired by design patterns to better organize my code.  A tip: don't get hung up on design patterns, but if they can help you think differently and be more organized and more concise, then the more power to you.

A design pattern that I am using in the new engine is the Entity/Component pattern.  This means that most objects in the game are Entities.  And they all can use various components.  It is a very modular way of programming, and while I am not fully using this pattern, it has inspired some great organization.  

An example:  Characters on the map can have a component called "Shake" which can be added to them, and if it is on their entity, they will shake.  Another component called "flash" could also be added and the entity then will flash the specified color.  And when I want these effects to stop I can remove those components.  

But components can be used for more than just effects.  They can be used for state changes, logical conditions, and even to help organize entity data into groupings which can be sync'd cross the network. 


3. Reusable Game Engine

Another great thing I am realizing is that now that I am starting to build this fantastic library of utilities is that it could be used to create another game easily.  Having the game logic for each game in their own projects but all referencing the same core engine, will allow me to create more games.  Now let's not get ahead of ourselves, but it is still a cool revelation.


In summary, the new game engine has been a great decision and I am rapidly making progress splitting a ton of new features into it, improving them along the way and of course making them much more organized and managable!  In the coming updates I will outline the features that have been added to the engine, share the design patterns that went into them, and explain how they have been improved.




Like 26


Jul 07 2017 at 12:33 AM

GSoster says

Nice! Organization and padronization are needed in any project. I hope it can help to make the game progress in a good pace :)

Post Comment

You need to Login in order to comment.