Missile Control Game with uLCD

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed wave_player

Fork of missile_command by ECE 2035 TA

Committer:
ajindia6
Date:
Tue Oct 20 19:13:03 2015 +0000
Revision:
2:eba4ed0263a4
Parent:
0:532cb55d6136
Mbed Mission Control Game

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arvahsu 0:532cb55d6136 1 #include "mbed.h"
arvahsu 0:532cb55d6136 2 #include "uLCD_4DGL.h"
arvahsu 0:532cb55d6136 3 #include "globals.h"
arvahsu 0:532cb55d6136 4 #include "player.h"
arvahsu 0:532cb55d6136 5
ajindia6 2:eba4ed0263a4 6 //Initialize antimissile status
ajindia6 2:eba4ed0263a4 7 PLAYER_MISSILE_STATUS status;
ajindia6 2:eba4ed0263a4 8
ajindia6 2:eba4ed0263a4 9
ajindia6 2:eba4ed0263a4 10
ajindia6 2:eba4ed0263a4 11
ajindia6 2:eba4ed0263a4 12
ajindia6 2:eba4ed0263a4 13 //Function to draw the player
arvahsu 0:532cb55d6136 14 void player_draw(int x, int y) {
ajindia6 2:eba4ed0263a4 15 uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, 0xFFA500);
ajindia6 2:eba4ed0263a4 16 uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, 0xFF0000);
ajindia6 2:eba4ed0263a4 17 uLCD.filled_rectangle(x,y, x+PLAYER_WIDTH/4, y+2+PLAYER_HEIGHT, 0xFFA500);
ajindia6 2:eba4ed0263a4 18 uLCD.filled_rectangle(x+8, y, x+PLAYER_WIDTH, y+2+PLAYER_HEIGHT, 0xFFA500);
ajindia6 2:eba4ed0263a4 19 }
ajindia6 2:eba4ed0263a4 20
ajindia6 2:eba4ed0263a4 21 //Function to delete player
ajindia6 2:eba4ed0263a4 22 void player_delete(int x, int y) {
ajindia6 2:eba4ed0263a4 23 uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, BLACK_COLOR);
ajindia6 2:eba4ed0263a4 24 uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, BLACK_COLOR);
ajindia6 2:eba4ed0263a4 25 uLCD.filled_rectangle(x,y, x+PLAYER_WIDTH/4, y+2+PLAYER_HEIGHT, BLACK_COLOR);
ajindia6 2:eba4ed0263a4 26 uLCD.filled_rectangle(x+8, y, x+PLAYER_WIDTH, y+2+PLAYER_HEIGHT, BLACK_COLOR);
arvahsu 0:532cb55d6136 27 }
arvahsu 0:532cb55d6136 28
arvahsu 0:532cb55d6136 29
ajindia6 2:eba4ed0263a4 30 void gameover(int s) {
ajindia6 2:eba4ed0263a4 31
ajindia6 2:eba4ed0263a4 32 while(1) {
ajindia6 2:eba4ed0263a4 33 uLCD.filled_rectangle(0, 0, 128, 128, 0x000000);
ajindia6 2:eba4ed0263a4 34 uLCD.locate(4, 5);
ajindia6 2:eba4ed0263a4 35 uLCD.printf("GAME OVER \n \n");
ajindia6 2:eba4ed0263a4 36 uLCD.printf("YOUR SCORE WAS:%2d",s);
ajindia6 2:eba4ed0263a4 37 wait(1);
ajindia6 2:eba4ed0263a4 38 }
ajindia6 2:eba4ed0263a4 39
ajindia6 2:eba4ed0263a4 40 }
ajindia6 2:eba4ed0263a4 41
arvahsu 0:532cb55d6136 42
ajindia6 2:eba4ed0263a4 43
ajindia6 2:eba4ed0263a4 44
ajindia6 2:eba4ed0263a4 45
ajindia6 2:eba4ed0263a4 46
ajindia6 2:eba4ed0263a4 47
ajindia6 2:eba4ed0263a4 48
ajindia6 2:eba4ed0263a4 49
ajindia6 2:eba4ed0263a4 50
ajindia6 2:eba4ed0263a4 51
ajindia6 2:eba4ed0263a4 52
ajindia6 2:eba4ed0263a4 53
ajindia6 2:eba4ed0263a4 54