Early commits of my project
Dependencies: mbed Gamepad N5110
Diff: Sprites.cpp
- Revision:
- 6:6294bf4eafc8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sprites.cpp Wed Mar 13 16:38:21 2019 +0000 @@ -0,0 +1,89 @@ +#include "Sprites.h" +#include "main.h" +#include "Gamepad.h" + +Gamepad pad; + +Sprites::Sprites() +{ +} + +Sprites::~Sprites() +{ +} + +void Sprites::miner_move(int x_direction, int y_direction) +{ + + + + const int miner_right[13][5] = { + 0,0,0,1,1, + 0,1,1,1,1, + 0,1,0,1,0, + 0,1,1,1,1, + 0,1,1,1,0, + 0,0,1,0,0, + 1,1,1,1,1, + 1,1,1,1,1, + 1,1,1,1,1, + 0,1,1,1,0, + 0,1,0,1,0, + 0,1,1,1,1, + }; + + const int miner_left[13][5] = { + 1,1,0,0,0, + 1,1,1,1,0, + 0,1,0,1,0, + 1,1,1,1,0, + 0,1,1,1,0, + 0,0,1,0,0, + 1,1,1,1,1, + 1,1,1,1,1, + 1,1,1,1,1, + 0,1,1,1,0, + 0,1,0,1,0, + 1,1,1,1,0, + }; + + lcd.clear(); + + + Direction d = pad.get_direction(); + printf("Direction = %i\n",d); + + lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); + + + if (d==3) { + + x_direction = x_direction + 1; + lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); + lcd.refresh(); + wait(0.05); + + } + + if (d == 7) { + + x_direction = x_direction - 1; + lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_left); + lcd.refresh(); + wait(0.05); + } + //lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); + //lcd.refresh(); + + if(pad.check_event(Gamepad::A_PRESSED)) { + + + printf("A pressed"); + y_direction = y_direction - 6; + lcd.clear(); + lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); + lcd.refresh(); + wait(0.2); + y_direction = y_direction + 6; + } +} \ No newline at end of file