pocket tanks
Dependencies: 4DGL-uLCD-SE pockettanks SDFileSystem mbed wave_player
Fork of ECE2035_FroggerGame_SUM1025 by
Diff: robot/robot.cpp
- Revision:
- 3:8f68c00dd75a
- Parent:
- 1:172fbc00199c
--- a/robot/robot.cpp Sun Oct 04 22:06:38 2015 +0000 +++ b/robot/robot.cpp Thu Oct 22 03:47:32 2015 +0000 @@ -5,13 +5,48 @@ // Following code will only draw the Robot on the screen. You are expected to modify most of the functions here. // All other necessary functions will be implemented by you. Ex: the movement of Robot, calculate the score ... etc. +/////////////////new/////////////////////// +/*DigitalIn right_pb(p21); // push bottom + int main() + { + right_pb.mode(PullUp); // The variable rightt_pb will be zero when the pushbutton for moving the player right is pressed + }*/ +////////////////////////////////////////////// void robot_init(int grid_x, int grid_y, double &score, bool& end){ map_eat_candy(grid_x,grid_y,score); //clear the cookie on the grid. robot_draw(grid_x,grid_y); + end = map_the_end(grid_x,grid_y); } +void robot_init1(int grid_a, int grid_b, double &score, bool& end){ + + map_eat_candy(grid_a,grid_b,score); //clear the cookie on the grid. + robot_draw(grid_a,grid_b); + + end = map_the_end(grid_a,grid_b); +} +void robot_shoot(int grid_x, int grid_y, int p){ + + GRID grid_info = map_get_grid_status(grid_x,grid_y); + // Calculate the actual position of the grid + int tank_x = grid_info.x + GRID_RADIUS; + int tank_y = grid_info.y + GRID_RADIUS; + //MOVE RIGHT + robot_clear(tank_x,tank_y); + map_draw_grid(tank_x,tank_y); + //x+=1; + + uLCD.line(tank_x+6,tank_y + 4,tank_x + 12, tank_y+p-1 , 0x00ffdf); + // p++; + uLCD.line(tank_x+7,tank_y + 4,tank_x + 12, tank_y+p , BLACK); + + + wait(0.1); + // robot_init(tank_x,tank_y,0,0,move); + + } void robot_draw(int grid_x, int grid_y){ @@ -19,26 +54,39 @@ // Calculate the actual position of the grid int tank_x = grid_info.x + GRID_RADIUS; int tank_y = grid_info.y + GRID_RADIUS; - // MAKE - /* - uLCD.filled_circle(frog_x, frog_y, 2, 0xCC0066); - uLCD.filled_rectangle(frog_x-2,frog_y+1,frog_x+2,frog_y+3,0x33FF66); - uLCD.line(frog_x-1, frog_y+4,frog_x-1, frog_y+5, 0xFF0000);//legs - uLCD.line(frog_x+2, frog_y+4,frog_x+2, frog_y+5, 0xFF0000); - uLCD.line(frog_x+2, frog_y+1,frog_x+4, frog_y+1, 0xFF0000);//hands - uLCD.line(frog_x-2, frog_y+1,frog_x-4, frog_y+1, 0xFF0000); - */ + + + uLCD.filled_rectangle(tank_x, tank_y, tank_x + 6, tank_y +8, RED); + uLCD.filled_circle(tank_x, tank_y+2, 2, BLACK); + uLCD.filled_circle(tank_x, tank_y+5, 2, BLACK); + uLCD.line(tank_x+6,tank_y + 4,tank_x + 12, tank_y+4 , BLACK); +} + +void robot_draw1(int grid_a, int grid_b){ - uLCD.filled_rectangle(tank_x, tank_y, tank_x + 10, tank_y +10, RED); - uLCD.filled_circle(tank_x, tank_y+3, 1, BLACK); - uLCD.filled_circle(tank_x, tank_y+7, 1, BLACK); - uLCD.line(tank_x+10,tank_y + 5,tank_x + 15, tank_y+5 , BLACK); + GRID grid_info = map_get_grid_status(grid_a,grid_b); + // Calculate the actual position of the grid + int tank_a = grid_info.x + GRID_RADIUS; + int tank_b = grid_info.y + GRID_RADIUS; + + + uLCD.filled_rectangle(tank_a, tank_b, tank_a + 6, tank_b + 8, RED); + uLCD.filled_circle(tank_a, tank_b+2, 2, BLACK); + uLCD.filled_circle(tank_a, tank_b+5, 2, BLACK); + uLCD.line(tank_a+6,tank_b + 4,tank_a + 12, tank_b+4 , BLACK); } void robot_clear(int grid_x, int grid_y){ GRID grid_info = map_get_grid_status(grid_x,grid_y); //Fill the grid (a rectangle) with BACKGROUND_COLOR to clear the pacman - uLCD.filled_rectangle(grid_info.x, grid_info.y, grid_info.x+GRID_SIZE-1, grid_info.y+GRID_SIZE-1, 0x198C19); + uLCD.filled_rectangle(grid_info.x, grid_info.y, grid_info.x+GRID_SIZE-1, grid_info.y+GRID_SIZE-1, 0x00ffdf); } +void robot_clear1(int grid_a, int grid_b){ + + GRID grid_info = map_get_grid_status(grid_a,grid_b); + //Fill the grid (a rectangle) with BACKGROUND_COLOR to clear the pacman + uLCD.filled_rectangle(grid_info.x, grid_info.y, grid_info.x+GRID_SIZE-1, grid_info.y+GRID_SIZE-1, 0x00ffdf); + +}