Saturday 26 April 2014

Day 2

Design tweaking and creating the initial code structure

Jack was sick and missed everything.
Kate and I worked together on creating the initial structure of the app. We created the classes, added variables and created empty functions defining the structure of the classes and how they would access each other.

We decided for the sake of simplicity, we would have a static class with references to the current Client, Engine and possibly the Graphics instance if needed. This makes communication between the client, engine and graphics code easier.

The main reason for that is that both the Engine and the Client need references to each other, and since you can't give an object a reference to an object that hasn't been created yet, you end up with a chicken-and-egg problem. For example, if you create the Client before the Engine, you cannot pass the Engine into it's constructor, and vice versa if you create the Engine first. The other solutions would be to pass a parent object to the Engine and Client, or add a setClient function called on the Engine after creation, but that seemed like an unneeded extra step. The other nice thing about storing it statically is that the Graphics object can access the Engine the same way the Client would without having to add extra code for setting up the Graphics object.

We also put some more thought into how the IO between the client and the server will work.
We had a conversation about how potentially adding single player and local multiplayer would effect the design and classes. We decided that we should be able to make a class that effectively works as a local server. It had previously been decided that any AI code should be a part of the Engine code. This could make having a local server be complicated. We will undoubtedly have to add one or more new classes in order to make it work. It would be a good idea to talk about this at the next meeting, as changing the design early on will be less costly.

Now that all the classes, functions and general program structure has been written out, we should be able to start programming the app and designing the server application.

No comments:

Post a Comment