Saturday, 10 February 2018


Week 3 – Game Engine

In the third part of the space game tutorial engine, or in the third week, we dig more into the inheritance idea. One of the first things which I have done, all my actions being instructed by the tutorial, was to create a new class entitled GameObject because all the following classes which will be created afterwards will inherit the equivalent functions which are written in the GameObject class. Basically, the asteroid and the spaceship class will inherit their functions, such as drawScene(), from the GameObject because at this point in time the asteroids and the spaceship have similar functions. The newly created class will consist of every function that is shared between the objects we have created and some of which will be created during the tutorial, it will contain functions and variables which will be needed by both of them classes, the asteroid and the spaceship. This demonstrates even better than the previous week, where I have talked about the importance of inheritance, how important this concept can be in programming, coming back to the idea of reusing the code. The output of the game is the same because I have not changed the position or the colour of the asteroids, I just followed the tutorial and I have created the class which will become the basis of the game, at least for now.

Images which show that the GameObject became the parent class and now the Asteroid and the SpaceShip class inherit from it:






No comments:

Post a Comment