ECE 2036 Project
Dependencies: mbed wave_player 4DGL-uLCD-SE
Diff: game.h
- Revision:
- 0:cf4396614a79
- Child:
- 2:2042f29de6b7
diff -r 000000000000 -r cf4396614a79 game.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/game.h Fri Nov 03 18:48:48 2017 +0000 @@ -0,0 +1,56 @@ +#pragma once + +#include "physics.h" +#include "doublely_linked_list.h" + +/* A structure for holding all the game inputs */ +struct GameInputs +{ + // Measurements from the accelerometer + double ax, ay, az; +}; + +////////////////////////// +// Arena Element structs +////////////////////////// +/** The basic ArenaElement structure. + Every item in an arena DLinkedList should be able to be cast to this struct. + The type member is used to tell what other struct this element might be. +*/ +struct ArenaElement { + int type; +}; + +// Element types +#define WALL 0 +#define BALL 1 + +/** An ArenaElement struct representing the ball. */ +struct Ball { + // ArenaElement type (must be first element) + int type; + // Drawing info + int x, y; +}; + +///////////////////////// +// ArenaElement helpers +///////////////////////// +/** Erases the ball */ +void erase_ball(Ball* ball); +/** Draws the ball at the current state */ +void draw_ball(Ball* ball, Physics* state); + +/* Add additional helpers for other ArenaElement types here */ + +/////////////////////////// +// Game control functions +/////////////////////////// +/* Reads all game inputs */ +GameInputs read_inputs(); + +/* Performs a single physics update. */ +int update_game(DLinkedList* arena, Physics* prev, GameInputs inputs, float delta); + +/* Implements the game loop */ +int run_game(DLinkedList* arena, Physics* state);