Missile Control Game with uLCD
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed wave_player
Fork of missile_command by
Diff: player.cpp
- Revision:
- 2:eba4ed0263a4
- Parent:
- 0:532cb55d6136
--- a/player.cpp Wed Oct 29 02:58:53 2014 +0000 +++ b/player.cpp Tue Oct 20 19:13:03 2015 +0000 @@ -1,37 +1,54 @@ -/* Gatech ECE2035 2014 FALL missile command - * Copyright (c) 2014 Gatech ECE2035 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// Template of player implementation #include "mbed.h" #include "uLCD_4DGL.h" #include "globals.h" #include "player.h" -// Example of drawing the player +//Initialize antimissile status +PLAYER_MISSILE_STATUS status; + + + + + +//Function to draw the player void player_draw(int x, int y) { - uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, PLAYER_COLOR); - uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, PLAYER_COLOR); + uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, 0xFFA500); + uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, 0xFF0000); + uLCD.filled_rectangle(x,y, x+PLAYER_WIDTH/4, y+2+PLAYER_HEIGHT, 0xFFA500); + uLCD.filled_rectangle(x+8, y, x+PLAYER_WIDTH, y+2+PLAYER_HEIGHT, 0xFFA500); +} + +//Function to delete player +void player_delete(int x, int y) { + uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, BLACK_COLOR); + uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, BLACK_COLOR); + uLCD.filled_rectangle(x,y, x+PLAYER_WIDTH/4, y+2+PLAYER_HEIGHT, BLACK_COLOR); + uLCD.filled_rectangle(x+8, y, x+PLAYER_WIDTH, y+2+PLAYER_HEIGHT, BLACK_COLOR); } -// ... You need to implement your own functions for player ... +void gameover(int s) { + + while(1) { + uLCD.filled_rectangle(0, 0, 128, 128, 0x000000); + uLCD.locate(4, 5); + uLCD.printf("GAME OVER \n \n"); + uLCD.printf("YOUR SCORE WAS:%2d",s); + wait(1); + } + + } + + + + + + + + + + + + +