Anda di halaman 1dari 4

Assignment 9

This assignment deals with using our knowledge of graphics and all the tricks we have learnt till now to
make an interactive game. I chose to make a simple snake game for this class. Eventually more features
will be added to the game
1. Game ControlsThe arrow keys to set the direction of the game.
W,A,S,D is used to move the camera.
Q,E is used to zoom the camera in and out.
2. Below is the screenshot of the game when it is initially loaded

The blue sphere here represents the head of the snake, and the red spheres represent its body.
The snake is moving towards the right hence it has advanced over to the right of the screen.
3. The user can set the direction for the snake to (up,left,right or down). However the snake cant
go in the reverse direction of what its current direction. i.e If the snake is going right it cant go
left onto itself and vice versa. Below is the screenshot of the game where the direction supplied
by the user is down and hence the snake starts to move down. Also once the head moves
down the body segments shift over to the heads position and hence simulate a train like motion.

4. Similarly the snake can move up or left as well.


5. This game has user controlled objects as well as computer controlled objectsa. The user influences the game by changing the direction of the game.
b. The computer influences the game by moving the snake constantly in its current direction.

6. Structuring of the codeI made the snake as a separate class. I basically made the Snake.h and Snake.cpp files. Below is
the structure of the Snake.h file and how it is structured.

Both the Snake.h and Snake.cpp files are included as part of the existing MyGame project.
A snake object is constructed in MyGame.cpp. It is deleted in cleanup and the draw function of
the snake is called in the method RunGame of MyGame.cpp. This is so because we want to draw
the snake every frame after calculating its updated position.
MyGame also has a method which detects which arrow key is pressed, once it detects this, it
passes the corresponding direction to the snake object.

7. Things to add to the game in the future.


a. Food for the snake will spawn at random locations and the player has to collect these. The
snake will grow in size as it collects these.
b. Making a boundary wall and detect snakes collision with it.
c. Increasing the speed of the game as it progresses through the game.
d. Adding better meshes.
e. (Possible goal) Adding this game into an inclined plane so that it looks better.

8. Game interacts with the engine via the snake object.


a. The snake has a method called Draw. This method creates a DrawableItem object (an
object with a mesh, the objects position, its rotation and the angle of rotation.
b. The Draw method then submits this DrawableItem to the Graphics system which takes
care of drawing it.
9. I had to create Snake.cpp as the additional class for this initial build of the game.
10. The code for setting the direction of the snake and its rotation is reusable. Also the code for
movement of the snake can be reused for a new game if needed.

Anda mungkin juga menyukai