ECE2035 class project
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed wave_player
Fork of missile_command by
player.h@5:3f356592ee9c, 2014-11-17 (annotated)
- Committer:
- slin77
- Date:
- Mon Nov 17 21:23:02 2014 +0000
- Revision:
- 5:3f356592ee9c
- Parent:
- 4:0dc720aa3c71
add big_shoot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arvahsu | 0:532cb55d6136 | 1 | /* Gatech ECE2035 2014 FALL missile command |
arvahsu | 0:532cb55d6136 | 2 | * Copyright (c) 2014 Gatech ECE2035 |
arvahsu | 0:532cb55d6136 | 3 | * |
arvahsu | 0:532cb55d6136 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
arvahsu | 0:532cb55d6136 | 5 | * of this software and associated documentation files (the "Software"), to deal |
arvahsu | 0:532cb55d6136 | 6 | * in the Software without restriction, including without limitation the rights |
arvahsu | 0:532cb55d6136 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
arvahsu | 0:532cb55d6136 | 8 | * copies of the Software, and to permit persons to whom the Software is |
arvahsu | 0:532cb55d6136 | 9 | * furnished to do so, subject to the following conditions: |
arvahsu | 0:532cb55d6136 | 10 | * |
arvahsu | 0:532cb55d6136 | 11 | * The above copyright notice and this permission notice shall be included in |
arvahsu | 0:532cb55d6136 | 12 | * all copies or substantial portions of the Software. |
arvahsu | 0:532cb55d6136 | 13 | * |
arvahsu | 0:532cb55d6136 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
arvahsu | 0:532cb55d6136 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
arvahsu | 0:532cb55d6136 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
arvahsu | 0:532cb55d6136 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
arvahsu | 0:532cb55d6136 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
arvahsu | 0:532cb55d6136 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
arvahsu | 0:532cb55d6136 | 20 | * SOFTWARE. |
arvahsu | 0:532cb55d6136 | 21 | */ |
arvahsu | 0:532cb55d6136 | 22 | |
arvahsu | 0:532cb55d6136 | 23 | // Template of player header file |
arvahsu | 0:532cb55d6136 | 24 | #ifndef PLAYER_H |
arvahsu | 0:532cb55d6136 | 25 | #define PLAYER_H |
arvahsu | 0:532cb55d6136 | 26 | |
arvahsu | 0:532cb55d6136 | 27 | // Example of some player settings |
arvahsu | 0:532cb55d6136 | 28 | #define PLAYER_WIDTH 10 |
arvahsu | 0:532cb55d6136 | 29 | #define PLAYER_HEIGHT 3 |
arvahsu | 0:532cb55d6136 | 30 | #define PLAYER_DELTA 3 |
arvahsu | 0:532cb55d6136 | 31 | #define PLAYER_COLOR 0x0000FF |
arvahsu | 0:532cb55d6136 | 32 | |
arvahsu | 0:532cb55d6136 | 33 | |
slin77 | 2:d39a6a36e0c0 | 34 | typedef enum { |
slin77 | 2:d39a6a36e0c0 | 35 | PLAYER_ACTIVE = 1, |
slin77 | 2:d39a6a36e0c0 | 36 | PLAYER_DIED = 0 |
slin77 | 2:d39a6a36e0c0 | 37 | } PLAYER_STATUS; |
slin77 | 2:d39a6a36e0c0 | 38 | |
slin77 | 2:d39a6a36e0c0 | 39 | |
slin77 | 2:d39a6a36e0c0 | 40 | typedef struct { |
slin77 | 2:d39a6a36e0c0 | 41 | int timer; |
slin77 | 2:d39a6a36e0c0 | 42 | int is_active; |
slin77 | 2:d39a6a36e0c0 | 43 | } PROTECTOR; |
slin77 | 2:d39a6a36e0c0 | 44 | |
slin77 | 2:d39a6a36e0c0 | 45 | typedef struct { |
slin77 | 2:d39a6a36e0c0 | 46 | int x;// the current x of the player, bottom left |
slin77 | 2:d39a6a36e0c0 | 47 | int y;//current y position of the player, bottom left point |
slin77 | 2:d39a6a36e0c0 | 48 | int max_am; |
slin77 | 2:d39a6a36e0c0 | 49 | int am_remain;//how many missile for the player remain |
slin77 | 2:d39a6a36e0c0 | 50 | int life;//his hp remain |
slin77 | 2:d39a6a36e0c0 | 51 | int current_level; |
slin77 | 2:d39a6a36e0c0 | 52 | PLAYER_STATUS status;//if he is dead |
slin77 | 2:d39a6a36e0c0 | 53 | int score;//# of interceptions |
slin77 | 2:d39a6a36e0c0 | 54 | int protector_num;// number of protector left |
slin77 | 4:0dc720aa3c71 | 55 | PROTECTOR protector; |
slin77 | 4:0dc720aa3c71 | 56 | int is_diagnoal; |
slin77 | 4:0dc720aa3c71 | 57 | int angle; |
slin77 | 4:0dc720aa3c71 | 58 | int timer; |
slin77 | 2:d39a6a36e0c0 | 59 | } PLAYER; |
slin77 | 2:d39a6a36e0c0 | 60 | /** et the information of city |
arvahsu | 0:532cb55d6136 | 61 | @brief x and y are the top left corner of the player drawing |
arvahsu | 0:532cb55d6136 | 62 | @param x x-coordinate |
arvahsu | 0:532cb55d6136 | 63 | @param y y-coordinate |
arvahsu | 0:532cb55d6136 | 64 | */ |
slin77 | 2:d39a6a36e0c0 | 65 | |
slin77 | 2:d39a6a36e0c0 | 66 | |
slin77 | 2:d39a6a36e0c0 | 67 | |
slin77 | 2:d39a6a36e0c0 | 68 | typedef enum { |
slin77 | 2:d39a6a36e0c0 | 69 | DEACTIVE = 0, |
slin77 | 2:d39a6a36e0c0 | 70 | ACTIVE = 1, |
slin77 | 2:d39a6a36e0c0 | 71 | //MISSLE_EXPLODE = 2 |
slin77 | 2:d39a6a36e0c0 | 72 | } ANTIMISSLE_STATUS; |
slin77 | 2:d39a6a36e0c0 | 73 | |
slin77 | 2:d39a6a36e0c0 | 74 | typedef struct { |
slin77 | 2:d39a6a36e0c0 | 75 | int x; |
slin77 | 2:d39a6a36e0c0 | 76 | int y; |
slin77 | 2:d39a6a36e0c0 | 77 | int speed; |
slin77 | 2:d39a6a36e0c0 | 78 | int tick; //anti missile's internal clock |
slin77 | 2:d39a6a36e0c0 | 79 | ANTIMISSLE_STATUS status; |
slin77 | 4:0dc720aa3c71 | 80 | int is_diagnoal; |
slin77 | 4:0dc720aa3c71 | 81 | int angle; |
slin77 | 2:d39a6a36e0c0 | 82 | } ANTIMISSILE; |
slin77 | 2:d39a6a36e0c0 | 83 | |
slin77 | 2:d39a6a36e0c0 | 84 | typedef enum{ |
slin77 | 2:d39a6a36e0c0 | 85 | YES = 1, |
slin77 | 2:d39a6a36e0c0 | 86 | NO = 0 |
slin77 | 2:d39a6a36e0c0 | 87 | } EXPLOSION_STATUS; |
arvahsu | 0:532cb55d6136 | 88 | |
slin77 | 2:d39a6a36e0c0 | 89 | typedef struct{ |
slin77 | 2:d39a6a36e0c0 | 90 | int x; |
slin77 | 2:d39a6a36e0c0 | 91 | int y; |
slin77 | 2:d39a6a36e0c0 | 92 | int tick; |
slin77 | 2:d39a6a36e0c0 | 93 | int radius; |
slin77 | 2:d39a6a36e0c0 | 94 | EXPLOSION_STATUS exploded; |
slin77 | 2:d39a6a36e0c0 | 95 | int color; |
slin77 | 2:d39a6a36e0c0 | 96 | } EXPLOSION; |
slin77 | 2:d39a6a36e0c0 | 97 | |
slin77 | 2:d39a6a36e0c0 | 98 | |
slin77 | 2:d39a6a36e0c0 | 99 | //initialize the player for the game |
slin77 | 2:d39a6a36e0c0 | 100 | void player_init(); |
slin77 | 2:d39a6a36e0c0 | 101 | void player_draw(); |
slin77 | 2:d39a6a36e0c0 | 102 | void player_move_left(); |
slin77 | 2:d39a6a36e0c0 | 103 | void player_move_right(); |
slin77 | 2:d39a6a36e0c0 | 104 | void antimissile_init(); |
slin77 | 2:d39a6a36e0c0 | 105 | void shoot(); |
slin77 | 2:d39a6a36e0c0 | 106 | void update_antimissile_positions(); |
slin77 | 2:d39a6a36e0c0 | 107 | void draw_antimissiles(); |
slin77 | 2:d39a6a36e0c0 | 108 | void explosion_init(); |
slin77 | 2:d39a6a36e0c0 | 109 | void update_explosion(); |
slin77 | 2:d39a6a36e0c0 | 110 | void draw_explosion(); |
slin77 | 2:d39a6a36e0c0 | 111 | void update_protector();// update protector status and draw it on the screen |
slin77 | 5:3f356592ee9c | 112 | void big_shoot();//shoot all remaining antimissile at random position |
slin77 | 2:d39a6a36e0c0 | 113 | |
slin77 | 2:d39a6a36e0c0 | 114 | //extern PLAYER current_player; |
slin77 | 2:d39a6a36e0c0 | 115 | //extern ANTIMISSILE am[5]; |
slin77 | 2:d39a6a36e0c0 | 116 | //extern EXPLOSION ex[5]; |
slin77 | 2:d39a6a36e0c0 | 117 | /** |
slin77 | 2:d39a6a36e0c0 | 118 | get the currrent player info |
slin77 | 2:d39a6a36e0c0 | 119 | */ |
slin77 | 2:d39a6a36e0c0 | 120 | PLAYER get_player_info(); |
arvahsu | 0:532cb55d6136 | 121 | #endif //PLAYER_H |