LibGDX jam second weekend

Quick recap

The second weekend have I focus on game play. I have a working AI that is targeting the player, it is very very simple so far. I haveÂ done input to a ship so I can steer it. There are physics so the ships can move and turn. I have a weapon system so I can shoot projectiles. I can detect hits and an particle system are running when a hit is accuring. The game look like this.

Moving from Entity to ECS

Going from an Entity that inheritance a general object to an Entity Component System have been very hard for me. I do like the simple entity for small games. It is very fast to get started with. The complexity are a lot smaller then an ECS. For small games I think I will stick with the entity setup. The problem is that I need to know almost the entire game before started because it is very inflexible to work with. But for fast small thing I do like it. It is very simple.

I have been working with Artemis now this week and the complexity is going up a lot compared to the simpler entity solution. But the more I work with ECSÂ the more I start to like it. The big question for me at the moment is how many components should I have and how many systems. I have read this article and he suggest that when you move from an entity inheritance to an ECS you have a one-to-one ratio between component and systems. Then when you get more used to it you can get it more to what you need. But I think when you start a project there are a good aim to have a one-to-one ratio.

Components

The components I have created so far are a Transform that handle where the entity are, the z-value on what plane things should be running manly for rendering, rotation and the scale. I Texture that just hold a sprite. Input that tell that this entity should handle manual inputs. AI that tell that the entity should be handled by a computer. Physic that handle velocity (what direction to move), speed and rotation speed. Explosion that just handle a particle effect, maybe I should make a more general particle component. Bomb that is a ball that is flying in a straight line, it have how long it will live and how much damage it should do. I don’t know how I should be doing with the different weapons so I’m doing different component for every weapons. Last have I the Ship, this have the health, max speed, max rotation speed and if can stop when you don’t press the button any more.

This is all the component I’m using at the moment. I will need some more weapons components. I don’t know if I should go withÂ many ships also, or if I can have just one ship.

Systems

Now to the fun part. All my systems and how I’m thinking with them.

In my GameLoopSystemInvocationStratey class have I only added so my none Logic system get the remaining delta. This is used in the render to get a smoother animation but with fewer logic ticks. This meen that I can have a logic calculation on 20 FPS but I run theÂ graphics on 60 FPS.

My SortedIteratingSystem are not changed, but my SortedRenderSystem have some addition. I have added so the camera are moving with the player ship, this is made in the begin method. In process method have I added delta calculation if the graphics running faster then the logics to make it look smoother. I have addedÂ particles with an explosion. I have also change the ZComparator to order with the highest number will be the one furthest up.

My AISystem just handle computer ships. It try to find the closest human and attack it. Need to make this more intelligent later on. So far it just turn to the player and go. I need to make it swing or slowly rotate against the player and not just jump to where the player is. This will give the computer an unfair advantage.

The last system for now are the WeaponSystem. So far it look like I will be building one system that handle all the different weapons instead of one system for every type of weapon. This might be a dumb thing to do. But I think it’s not that hard to split it if I need to do that later. When I’m looking at it while writing I think this isn’t the best way to go. Might split it tomorrow.

I do hope you find this post some what informative in the problem I have. There aren’t that many explanation how I have solved stuff. Just some feelings I have against ECS and moving from an Entity object. Hopefully things have sattle more to next weekend so I can give more information how I solve things. If you have any thoughts just give a comment and I will help as best as I can.