ECE 2036 Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE

Committer:
rconnorlawson
Date:
Fri Nov 03 18:48:48 2017 +0000
Revision:
0:cf4396614a79
Child:
2:2042f29de6b7
Emptied shell code (including doubly linked list) and added comments for all the functionality.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rconnorlawson 0:cf4396614a79 1 #pragma once
rconnorlawson 0:cf4396614a79 2
rconnorlawson 0:cf4396614a79 3 #include "physics.h"
rconnorlawson 0:cf4396614a79 4 #include "doublely_linked_list.h"
rconnorlawson 0:cf4396614a79 5
rconnorlawson 0:cf4396614a79 6 /* A structure for holding all the game inputs */
rconnorlawson 0:cf4396614a79 7 struct GameInputs
rconnorlawson 0:cf4396614a79 8 {
rconnorlawson 0:cf4396614a79 9 // Measurements from the accelerometer
rconnorlawson 0:cf4396614a79 10 double ax, ay, az;
rconnorlawson 0:cf4396614a79 11 };
rconnorlawson 0:cf4396614a79 12
rconnorlawson 0:cf4396614a79 13 //////////////////////////
rconnorlawson 0:cf4396614a79 14 // Arena Element structs
rconnorlawson 0:cf4396614a79 15 //////////////////////////
rconnorlawson 0:cf4396614a79 16 /** The basic ArenaElement structure.
rconnorlawson 0:cf4396614a79 17 Every item in an arena DLinkedList should be able to be cast to this struct.
rconnorlawson 0:cf4396614a79 18 The type member is used to tell what other struct this element might be.
rconnorlawson 0:cf4396614a79 19 */
rconnorlawson 0:cf4396614a79 20 struct ArenaElement {
rconnorlawson 0:cf4396614a79 21 int type;
rconnorlawson 0:cf4396614a79 22 };
rconnorlawson 0:cf4396614a79 23
rconnorlawson 0:cf4396614a79 24 // Element types
rconnorlawson 0:cf4396614a79 25 #define WALL 0
rconnorlawson 0:cf4396614a79 26 #define BALL 1
rconnorlawson 0:cf4396614a79 27
rconnorlawson 0:cf4396614a79 28 /** An ArenaElement struct representing the ball. */
rconnorlawson 0:cf4396614a79 29 struct Ball {
rconnorlawson 0:cf4396614a79 30 // ArenaElement type (must be first element)
rconnorlawson 0:cf4396614a79 31 int type;
rconnorlawson 0:cf4396614a79 32 // Drawing info
rconnorlawson 0:cf4396614a79 33 int x, y;
rconnorlawson 0:cf4396614a79 34 };
rconnorlawson 0:cf4396614a79 35
rconnorlawson 0:cf4396614a79 36 /////////////////////////
rconnorlawson 0:cf4396614a79 37 // ArenaElement helpers
rconnorlawson 0:cf4396614a79 38 /////////////////////////
rconnorlawson 0:cf4396614a79 39 /** Erases the ball */
rconnorlawson 0:cf4396614a79 40 void erase_ball(Ball* ball);
rconnorlawson 0:cf4396614a79 41 /** Draws the ball at the current state */
rconnorlawson 0:cf4396614a79 42 void draw_ball(Ball* ball, Physics* state);
rconnorlawson 0:cf4396614a79 43
rconnorlawson 0:cf4396614a79 44 /* Add additional helpers for other ArenaElement types here */
rconnorlawson 0:cf4396614a79 45
rconnorlawson 0:cf4396614a79 46 ///////////////////////////
rconnorlawson 0:cf4396614a79 47 // Game control functions
rconnorlawson 0:cf4396614a79 48 ///////////////////////////
rconnorlawson 0:cf4396614a79 49 /* Reads all game inputs */
rconnorlawson 0:cf4396614a79 50 GameInputs read_inputs();
rconnorlawson 0:cf4396614a79 51
rconnorlawson 0:cf4396614a79 52 /* Performs a single physics update. */
rconnorlawson 0:cf4396614a79 53 int update_game(DLinkedList* arena, Physics* prev, GameInputs inputs, float delta);
rconnorlawson 0:cf4396614a79 54
rconnorlawson 0:cf4396614a79 55 /* Implements the game loop */
rconnorlawson 0:cf4396614a79 56 int run_game(DLinkedList* arena, Physics* state);