pocket tanks

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

Fork of ECE2035_FroggerGame_SUM1025 by Le Tran

robot/robot.cpp

Committer:
ece2035ta
Date:
2015-10-04
Revision:
1:172fbc00199c
Parent:
0:7fe3c940e4b5
Child:
3:8f68c00dd75a

File content as of revision 1:172fbc00199c:

#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 Robot, calculate the score ... etc.

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_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 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 + 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);
}

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);
    
}