ELEC2645 (2019/20)
/
ELEC2645_Project_el18jb
test 1 doc
Diff: Coin/Coin.cpp
- Revision:
- 11:b3024ab59fa5
- Child:
- 12:eb8d30593e95
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Coin/Coin.cpp Wed May 27 03:52:11 2020 +0000 @@ -0,0 +1,55 @@ +#include "Coin.h" + +Coin::Coin(int x, int y) +{ + _x = x; + _y = y; +} + +Coin::~Coin() +{ + +} + + +void Coin::draw(N5110 &lcd) +{ + for(int i = 5; i < 7 ; i++ ) { + lcd.drawCircle(_x, _y, i, FILL_TRANSPARENT); + } + for(int i = 7; i > 5 ; i-- ) { + lcd.drawCircle(_x, _y, i, FILL_TRANSPARENT); + } +} + +void Coin::show(Gamepad &pad) +{ + if(_x < WIDTH/2) { + side = 1; + } else { + side = 0; + } + + if(side ==1 && _y <= HEIGHT/3) { + pad.led(1, 0.5); + } + + if(side ==1 && _y < HEIGHT /3 && _y >= HEIGHT/3) { + pad.led(2, 0.5); + } + + if(side ==1 && _y >= HEIGHT/3) { + pad.led(3, 0.5); + } + if(side ==0 && _y <= HEIGHT/3) { + pad.led(4, 0.5); + } + + if(side ==0 && _y < HEIGHT /3 && _y >= HEIGHT/3) { + pad.led(5, 0.5); + } + + if(side ==0 && _y >= HEIGHT/3) { + pad.led(6, 0.5); + } +} \ No newline at end of file