Early commits of my project
Dependencies: mbed Gamepad N5110
Sprites.cpp
- Committer:
- el17arm
- Date:
- 2019-03-13
- Revision:
- 6:6294bf4eafc8
File content as of revision 6:6294bf4eafc8:
#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; } }