ECE 2036 Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers game.h Source File

game.h

00001 #pragma once
00002 
00003 #include "physics.h"
00004 #include "doublely_linked_list.h "
00005 
00006 /* A structure for holding all the game inputs */
00007 struct GameInputs {
00008     // Measurements from the accelerometer
00009     double ax, ay, az;
00010 };
00011 
00012 //////////////////////////
00013 // Arena Element structs
00014 //////////////////////////
00015 /** The basic ArenaElement structure.
00016     Every item in an arena DLinkedList should be able to be cast to this struct.
00017     The type member is used to tell what other struct this element might be.
00018 */
00019 struct ArenaElement {
00020     int type;
00021 };
00022 
00023 // Element types
00024 #define WALL        0
00025 #define BALL        1
00026 #define GOAL        2
00027 #define HOLE        3
00028 
00029 /** An ArenaElement struct representing the ball. */
00030 struct Ball {
00031     // ArenaElement type (must be first element)
00032     int type;
00033     // Drawing info
00034     int x, y;
00035 };
00036 
00037 /** An ArenaElement struct representing the goal. */
00038 struct Goal {
00039     // ArenaElement type (must be first element)
00040     int type;
00041     // Drawing info
00042     int x, y;
00043     int should_draw;
00044 };
00045 
00046 /** An ArenaElement struct representing a hole. */
00047 struct Hole {
00048     // ArenaElement type (must be first element)
00049     int type;
00050     // Drawing info
00051     int x, y;
00052     int should_draw;
00053 };
00054 
00055 /////////////////////////
00056 // ArenaElement helpers
00057 /////////////////////////
00058 /** Erases the ball */
00059 void erase_ball(Ball* ball);
00060 /** Draws the ball at the current state */
00061 void draw_ball(Ball* ball, Physics* state);
00062 
00063 /* Add additional helpers for other ArenaElement types here */
00064 
00065 /** Draws the goal */
00066 void draw_goal(Goal* goal);
00067 /** Draws a hole */
00068 void draw_hole(Hole* hole);
00069 
00070 ///////////////////////////
00071 // Game control functions
00072 ///////////////////////////
00073 /* Reads all game inputs */
00074 GameInputs read_inputs();
00075 
00076 /* Performs a single physics update. */
00077 int update_game(DLinkedList* arena, Physics* prev, GameInputs inputs, float delta);
00078 
00079 /* Implements the game loop */
00080 int run_game(DLinkedList* arena, Physics* state);