frogger game revision

Dependencies:   4DGL-uLCD-SE MMA8452 SDFileSystem mbed wave_player

Dependents:   C_Assembly

Fork of ECE2035_FroggerGame_SUM2015 by ECE 2035

robot/robot.cpp

Committer:
ece2035ta
Date:
2015-07-05
Revision:
6:5ed435a31cc7
Parent:
0:7fe3c940e4b5
Child:
7:b9b305de0fbb

File content as of revision 6:5ed435a31cc7:

#include "mbed.h"
#include "globals.h"
#include "map_public.h"
#include "robot.h"

// 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 roboFrogger, calculate the score ... etc.

void robot_init(int grid_x, int grid_y){

    map_eat_candy(grid_x,grid_y); //clear the candy on the grid.
    robot_draw(grid_x,grid_y);

}

void robot_draw(int grid_x, int grid_y){
    
    GRID grid_info = map_get_grid_status(grid_x,grid_y);
    // Calculate the actual position of the grid
    int frog_x = grid_info.x + GRID_RADIUS;
    int frog_y = grid_info.y + GRID_RADIUS;
    
    // MAKE
    uLCD.filled_circle(frog_x, frog_y, 3, 0x909090);
    uLCD.filled_rectangle(frog_x-3,frog_y+1,frog_x+3,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+4, frog_y+1,frog_x+5, frog_y+1, 0xFF0000);//hands
    uLCD.line(frog_x-4, frog_y+1,frog_x-5, frog_y+1, 0xFF0000); 
}

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 roboFrogger
    uLCD.filled_rectangle(grid_info.x, grid_info.y, grid_info.x+GRID_SIZE-1, grid_info.y+GRID_SIZE-1, BACKGROUND_COLOR);
    
}