Paradigm Shift, part 1

It has been quiet lately on this blog, and that is because of two very busy weeks.

Last Friday the first usable build of Ophelia was complete. To try it out, I created a game, a simple version of pong. Immediately, it was apparent that there was a major issue. All the game logic (strictly client side scripts), demanded attention to be paid to whether they ran on a host or a client, which completely contradicts the stated goal of the project. First, I looked at whether this could be fixed by providing a system for automatically determining what should happen on host and on client, but this was only applicable on internal engine functions (where it is was already applied). When a user wanted to, in Pong for example, create a paddle on the left for player 1 and one on the right for player 2, they had to check whether they were player 1 or 2 and create the right object locally. This was then distributed to the other client. But that requires running two separate scripts! Alternatively, the user could create all objects on the host, but now this script must only execute on the host.

Looking at these problems, I decided that a retooling of the engine’s structure was necessary to meet the projects goals. This time, the end user’s interface should be the primary focus. However, there is only so much project time, so a complete rewrite is out of the question.

The most effective solution was to place game logic on the server, instead on the client. This turns the clients into shell applications that only send input and receive data about what they should render on the screen. With this structure, game logic can now be written to only run in one place, the server, treating the player’s as abstract objects in the game.

Converting the design of Ophelia to this structure is very easy in theory, most systems will work exactly the same, only in a different place. But we have to remember that Ophelia’s server is an Express application, so attention also had to be payed to how one such application is put together to run user scripts.

Continue reading in part to find out what Ophelia’s new structure looks like!

Be Sociable, Share!

Published by

Albert Öhrling

Studies computer science in Skellefteå, at Lulea University of Technology.

Leave a Reply

Your email address will not be published. Required fields are marked *