martedì 22 novembre 2016

Day 190: New message format

Today I started by fixing a few problems, like the impossibility to set a network object in a certain position without having to lerp. So I added a reset_position method which reset the cache and set the position immediately. I also fixed a delay at the beginning of the game that made the objects spawn only after the first time update.
Then I noticed that the messages of my games were defined inside the engine, so I tried to move them in the client, but after an hour I had to rollback, because the use of unions and inheritance are quite problematic. Also the client class now handles many important aspects of the game, and this refactoring would have implied a migration of many functionalities directly in the game code, which is not ideal.
So in the end I decided to abstract the types of messages directly in the engine, so that they can be used by any king of game. For instance I created a Object_Update message which contains position, scale and rotation about the object. To make this system adaptable, I added to this message a selector code: if the game has two different kind of objects, he can use the same message with a different selector which will  be defined in the game code, and will allow to handle the message differently. I'll use this feature soon because I'll probably add a Ball class to the game.
In the end I also had to adapt the prediciton class inside the NetworkObject to also account for rotation and scaling (picture below), and I also improved the way in which it handles data conversion.


Nessun commento:

Posta un commento