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
Diff: Minerengine.cpp
- Revision:
- 1:813ba5341985
- Parent:
- 0:fe19852199d2
- Child:
- 2:725c213b2396
--- a/Minerengine.cpp Tue Mar 19 09:49:12 2019 +0000
+++ b/Minerengine.cpp Tue Mar 19 14:48:40 2019 +0000
@@ -4,44 +4,57 @@
{
}
-void Minerengine::minermove(N5110 &lcd, Gamepad &pad)
+Minerengine::~Minerengine()
{
+}
- printf("hello world /n");
- lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right);
-
- Direction d = pad.get_direction();
- printf("Direction = %i\n",d);
+void Minerengine::read_direction(Gamepad &pad)
+{
+ _d = pad.get_direction();
+ printf("direction %i \n", _d);
+}
- if (d==3) {
-
- x_direction = x_direction + 1;
- lcd.clear();
- lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right);
- lcd.refresh();
- wait(0.05);
+void Minerengine::miner_move()
+{
+ if (_d==3) {
+ _x = _x + 1;
+ _direction = 1;
}
-
- if (d == 7) {
+ if (_d==7) {
+ _x = _x - 1;
+ _direction = 0;
+ }
+ printf(" x = %i \n", _x);
+}
- x_direction = x_direction - 1;
- lcd.clear();
- lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_left);
- lcd.refresh();
- wait(0.05);
+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(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_right);
+
+ }
}
- //lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner);
- lcd.refresh();
+ if(_d==7 && pad.check_event(Gamepad::A_PRESSED))
+ {
+ for (int i = 0; i < 6; i++)
+ {
+ _y = _y -1;
+ lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_left);
+
+ }
+ }
+}
- 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);
- wait(0.2);
- y_direction = y_direction + 6;
-
+void Minerengine::miner_draw(N5110 &lcd)
+{
+ if (_direction == 1)
+ {
+ lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_right);
+ }
+ if (_direction == 0)
+ {
+ lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_left);
}
}
\ No newline at end of file