ECE2035 Spring 2015 TA / Mbed 2 deprecated 2035_Badminton_Shell

Dependencies:   4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem Sound mbed-rtos mbed wave_player

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers game.h Source File

game.h

00001 #ifndef GAME_H_
00002 #define GAME_H_
00003 
00004 // COLLISION_CODES returned by update_shuttle. Simplifies processing in main.
00005 enum Collision_Codes
00006 {
00007     NO_COLLISION,               // no collision detected
00008     CONT_VOLLEY,                // collision detected; continue volley
00009     POINT_P1,                   // player 1 scores
00010     POINT_P2                    // player 2 scores
00011 };
00012 
00013 typedef struct racket
00014 {
00015     int player;         // PLAYER1 or PLAYER2
00016     int x, y;           // center x and y positions
00017     int width, height;  // width and height of racket
00018     int x0, y0;         // initial positions before jump
00019     float vx0, vy0;     // initial velocities of racket
00020     float time_elapsed; // cumulative time in air
00021     bool has_jumped;    // if the player has jumped and is in the air
00022     int points;         // points per player
00023 } racket;
00024 
00025 typedef struct shuttle
00026 {
00027     int x0, y0;                 // initial positions per volley
00028     float vx0, vy0;             // initial velocities per volley
00029     int x, y;                   // current positions of shuttle
00030     float time_elapsed;         // cumulative time in air
00031     bool is_live;               // if shuttle has been served
00032     racket *last_possession;    // last player to touch shuttle
00033 } shuttle;
00034 
00035 // Initialize racket struct members. Int parameter identifies PLAYER1 or PLAYER2.
00036 void init_racket(racket*, int);
00037 
00038 // Calculates next position, both running and jumping, of racket using kinematic
00039 // equations.
00040 void update_racket(racket*, shuttle*, float);
00041 
00042 // Initialize shuttle struct members. Racket* parameter is player starting with
00043 // shuttle.
00044 void init_shuttle(shuttle*, racket*);
00045 
00046 // Calculate the next position of the shuttle using the kinematic equations. Return
00047 // collision code.
00048 int update_shuttle(GSYNC*, racket*, shuttle*);
00049 
00050 #endif