![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
frogger game revision
Dependencies: 4DGL-uLCD-SE MMA8452 SDFileSystem mbed wave_player
Fork of ECE2035_FroggerGame_SUM2015 by
robot/robot.cpp@9:47f07aa85f1a, 2016-02-01 (annotated)
- Committer:
- ssong86
- Date:
- Mon Feb 01 06:43:06 2016 +0000
- Revision:
- 9:47f07aa85f1a
- Parent:
- 7:b9b305de0fbb
frogger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leuyentran | 0:7fe3c940e4b5 | 1 | #include "mbed.h" |
leuyentran | 0:7fe3c940e4b5 | 2 | #include "globals.h" |
leuyentran | 0:7fe3c940e4b5 | 3 | #include "map_public.h" |
leuyentran | 0:7fe3c940e4b5 | 4 | #include "robot.h" |
leuyentran | 0:7fe3c940e4b5 | 5 | |
leuyentran | 0:7fe3c940e4b5 | 6 | // Following code will only draw the Robot on the screen. You are expected to modify most of the functions here. |
ece2035ta | 6:5ed435a31cc7 | 7 | // All other necessary functions will be implemented by you. Ex: the movement of roboFrogger, calculate the score ... etc. |
leuyentran | 0:7fe3c940e4b5 | 8 | |
leuyentran | 0:7fe3c940e4b5 | 9 | void robot_init(int grid_x, int grid_y){ |
leuyentran | 0:7fe3c940e4b5 | 10 | |
ece2035ta | 6:5ed435a31cc7 | 11 | map_eat_candy(grid_x,grid_y); //clear the candy on the grid. |
leuyentran | 0:7fe3c940e4b5 | 12 | robot_draw(grid_x,grid_y); |
leuyentran | 0:7fe3c940e4b5 | 13 | |
leuyentran | 0:7fe3c940e4b5 | 14 | } |
leuyentran | 0:7fe3c940e4b5 | 15 | |
leuyentran | 0:7fe3c940e4b5 | 16 | void robot_draw(int grid_x, int grid_y){ |
leuyentran | 0:7fe3c940e4b5 | 17 | |
leuyentran | 0:7fe3c940e4b5 | 18 | GRID grid_info = map_get_grid_status(grid_x,grid_y); |
leuyentran | 0:7fe3c940e4b5 | 19 | // Calculate the actual position of the grid |
leuyentran | 0:7fe3c940e4b5 | 20 | int frog_x = grid_info.x + GRID_RADIUS; |
leuyentran | 0:7fe3c940e4b5 | 21 | int frog_y = grid_info.y + GRID_RADIUS; |
leuyentran | 0:7fe3c940e4b5 | 22 | |
leuyentran | 0:7fe3c940e4b5 | 23 | // MAKE |
ece2035ta | 7:b9b305de0fbb | 24 | uLCD.filled_circle(frog_x, frog_y, 2, 0xCC0066); |
ece2035ta | 7:b9b305de0fbb | 25 | uLCD.filled_rectangle(frog_x-2,frog_y+1,frog_x+2,frog_y+3,0x33FF66); |
ssong86 | 9:47f07aa85f1a | 26 | //uLCD.line(frog_x-1, frog_y+4,frog_x-1, frog_y+5, 0xFF0000);//legs |
ssong86 | 9:47f07aa85f1a | 27 | //uLCD.line(frog_x+2, frog_y+4,frog_x+2, frog_y+5, 0xFF0000); |
ece2035ta | 7:b9b305de0fbb | 28 | uLCD.line(frog_x+2, frog_y+1,frog_x+4, frog_y+1, 0xFF0000);//hands |
ece2035ta | 7:b9b305de0fbb | 29 | uLCD.line(frog_x-2, frog_y+1,frog_x-4, frog_y+1, 0xFF0000); |
leuyentran | 0:7fe3c940e4b5 | 30 | } |
leuyentran | 0:7fe3c940e4b5 | 31 | |
leuyentran | 0:7fe3c940e4b5 | 32 | void robot_clear(int grid_x, int grid_y){ |
leuyentran | 0:7fe3c940e4b5 | 33 | |
leuyentran | 0:7fe3c940e4b5 | 34 | GRID grid_info = map_get_grid_status(grid_x,grid_y); |
ece2035ta | 6:5ed435a31cc7 | 35 | //Fill the grid (a rectangle) with BACKGROUND_COLOR to clear the roboFrogger |
leuyentran | 0:7fe3c940e4b5 | 36 | uLCD.filled_rectangle(grid_info.x, grid_info.y, grid_info.x+GRID_SIZE-1, grid_info.y+GRID_SIZE-1, BACKGROUND_COLOR); |
leuyentran | 0:7fe3c940e4b5 | 37 | |
leuyentran | 0:7fe3c940e4b5 | 38 | } |