test 1 doc

Dependencies:   mbed Gamepad2

Coin/Coin.cpp

Committer:
joebarhouch
Date:
2020-05-27
Revision:
14:58887d7e1072
Parent:
13:cb5ed2f0cbd5

File content as of revision 14:58887d7e1072:

#include "Coin.h"

Coin::Coin()
{
}

Coin::~Coin()
{

}

void Coin::init(){
        _x = WIDTH /2;
        _y = HEIGHT /2 -5;
    }

void Coin::draw(N5110 &lcd)
{
        lcd.drawCircle(_x, _y, 1, FILL_TRANSPARENT);
        lcd.drawCircle(_x, _y, 2, FILL_TRANSPARENT);
  
}

void Coin::show(Gamepad &pad)
{
    if(_x < WIDTH/2) {
        side  = 1;
    } else {
        side = 0;
    }

    if(side ==1 && _y <= HEIGHT/3) {
        pad.leds_off();
        pad.led(1, 0.5);
    }

    if(side ==1 && _y < HEIGHT *2/3 && _y >= HEIGHT/3) {
        pad.leds_off();
        pad.led(2, 0.5);
    }

    if(side ==1 && _y >= HEIGHT*2/3) {
        pad.leds_off();
        pad.led(3, 0.5);
    }
    if(side ==0 && _y <= HEIGHT/3) {
        pad.leds_off();
        pad.led(4, 0.5);
    }

    if(side ==0 && _y < HEIGHT* 2/3 && _y >= HEIGHT/3) {
        pad.leds_off();
        pad.led(5, 0.5);
    }

    if(side ==0 && _y >= HEIGHT*2/3) {
        pad.leds_off();
        pad.led(6, 0.5);
    }
}

void Coin::set_pos(int X, int Y){
        _x = X;
        _y = Y;
    }
    
//accessor
Vector2D Coin::get_pos()
{
    Vector2D pos = {_x, _y};
    return pos;
}