Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Minerengine.cpp
- Committer:
- el17arm
- Date:
- 2019-03-20
- Revision:
- 2:725c213b2396
- Parent:
- 1:813ba5341985
- Child:
- 3:d27ee2440829
File content as of revision 2:725c213b2396:
#include "Minerengine.h"
Minerengine::Minerengine()
{
_x = 0;
_y = 33;
}
Minerengine::~Minerengine()
{
}
void Minerengine::read_direction(Gamepad &pad)
{
_d = pad.get_direction();
printf("direction %i \n", _d);
}
void Minerengine::miner_move()
{
if (_d==3) {
_x = _x + 1;
_direction = 1;
}
if (_d==7) {
_x = _x - 1;
_direction = 0;
}
printf(" x = %i \n", _x);
}
void Minerengine::miner_jump(N5110 &lcd, Gamepad &pad)
{
if(_d==3 && pad.check_event(Gamepad::A_PRESSED)) {
for (int i = 0; i < 6; i++) {
_y = _y -1;
lcd.drawSprite(_x,_y,12,5,(int *)miner_right);
}
}
if(_d==7 && pad.check_event(Gamepad::A_PRESSED)) {
for (int i = 0; i < 6; i++) {
_y = _y -1;
lcd.drawSprite(_x,_y,12,5,(int *)miner_left);
}
}
if(_d==0 && pad.check_event(Gamepad::A_PRESSED)) {
for (int i = 0; i < 6; i++) {
_y = _y -1;
lcd.drawSprite(_x,_y,12,5,(int *)miner_left);
}
}
}
void Minerengine::miner_draw(N5110 &lcd)
{
if (_direction == 1) {
lcd.drawSprite(_x,_y,12,5,(int *)miner_right);
}
if (_direction == 0) {
lcd.drawSprite(_x,_y,12,5,(int *)miner_left);
}
}