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@2:725c213b2396, 2019-03-20 (annotated)
- Committer:
- el17arm
- Date:
- Wed Mar 20 01:32:31 2019 +0000
- Revision:
- 2:725c213b2396
- Parent:
- 1:813ba5341985
- Child:
- 3:d27ee2440829
Collision now detected though sprite does not react to collision yet
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17arm | 0:fe19852199d2 | 1 | #include "Minerengine.h" |
| el17arm | 0:fe19852199d2 | 2 | |
| el17arm | 0:fe19852199d2 | 3 | Minerengine::Minerengine() |
| el17arm | 2:725c213b2396 | 4 | |
| el17arm | 0:fe19852199d2 | 5 | { |
| el17arm | 2:725c213b2396 | 6 | _x = 0; |
| el17arm | 2:725c213b2396 | 7 | _y = 33; |
| el17arm | 0:fe19852199d2 | 8 | } |
| el17arm | 0:fe19852199d2 | 9 | |
| el17arm | 1:813ba5341985 | 10 | Minerengine::~Minerengine() |
| el17arm | 0:fe19852199d2 | 11 | { |
| el17arm | 1:813ba5341985 | 12 | } |
| el17arm | 0:fe19852199d2 | 13 | |
| el17arm | 1:813ba5341985 | 14 | void Minerengine::read_direction(Gamepad &pad) |
| el17arm | 1:813ba5341985 | 15 | { |
| el17arm | 1:813ba5341985 | 16 | _d = pad.get_direction(); |
| el17arm | 1:813ba5341985 | 17 | printf("direction %i \n", _d); |
| el17arm | 1:813ba5341985 | 18 | } |
| el17arm | 0:fe19852199d2 | 19 | |
| el17arm | 1:813ba5341985 | 20 | void Minerengine::miner_move() |
| el17arm | 1:813ba5341985 | 21 | { |
| el17arm | 1:813ba5341985 | 22 | if (_d==3) { |
| el17arm | 1:813ba5341985 | 23 | _x = _x + 1; |
| el17arm | 1:813ba5341985 | 24 | _direction = 1; |
| el17arm | 0:fe19852199d2 | 25 | } |
| el17arm | 1:813ba5341985 | 26 | if (_d==7) { |
| el17arm | 1:813ba5341985 | 27 | _x = _x - 1; |
| el17arm | 1:813ba5341985 | 28 | _direction = 0; |
| el17arm | 1:813ba5341985 | 29 | } |
| el17arm | 1:813ba5341985 | 30 | printf(" x = %i \n", _x); |
| el17arm | 1:813ba5341985 | 31 | } |
| el17arm | 0:fe19852199d2 | 32 | |
| el17arm | 1:813ba5341985 | 33 | void Minerengine::miner_jump(N5110 &lcd, Gamepad &pad) |
| el17arm | 1:813ba5341985 | 34 | { |
| el17arm | 1:813ba5341985 | 35 | if(_d==3 && pad.check_event(Gamepad::A_PRESSED)) { |
| el17arm | 2:725c213b2396 | 36 | for (int i = 0; i < 6; i++) { |
| el17arm | 1:813ba5341985 | 37 | _y = _y -1; |
| el17arm | 2:725c213b2396 | 38 | lcd.drawSprite(_x,_y,12,5,(int *)miner_right); |
| el17arm | 2:725c213b2396 | 39 | |
| el17arm | 1:813ba5341985 | 40 | } |
| el17arm | 0:fe19852199d2 | 41 | } |
| el17arm | 2:725c213b2396 | 42 | if(_d==7 && pad.check_event(Gamepad::A_PRESSED)) { |
| el17arm | 2:725c213b2396 | 43 | for (int i = 0; i < 6; i++) { |
| el17arm | 1:813ba5341985 | 44 | _y = _y -1; |
| el17arm | 2:725c213b2396 | 45 | lcd.drawSprite(_x,_y,12,5,(int *)miner_left); |
| el17arm | 2:725c213b2396 | 46 | |
| el17arm | 2:725c213b2396 | 47 | } |
| el17arm | 2:725c213b2396 | 48 | } |
| el17arm | 2:725c213b2396 | 49 | if(_d==0 && pad.check_event(Gamepad::A_PRESSED)) { |
| el17arm | 2:725c213b2396 | 50 | for (int i = 0; i < 6; i++) { |
| el17arm | 2:725c213b2396 | 51 | _y = _y -1; |
| el17arm | 2:725c213b2396 | 52 | lcd.drawSprite(_x,_y,12,5,(int *)miner_left); |
| el17arm | 1:813ba5341985 | 53 | } |
| el17arm | 1:813ba5341985 | 54 | } |
| el17arm | 1:813ba5341985 | 55 | } |
| el17arm | 0:fe19852199d2 | 56 | |
| el17arm | 1:813ba5341985 | 57 | void Minerengine::miner_draw(N5110 &lcd) |
| el17arm | 1:813ba5341985 | 58 | { |
| el17arm | 2:725c213b2396 | 59 | if (_direction == 1) { |
| el17arm | 2:725c213b2396 | 60 | lcd.drawSprite(_x,_y,12,5,(int *)miner_right); |
| el17arm | 1:813ba5341985 | 61 | } |
| el17arm | 2:725c213b2396 | 62 | if (_direction == 0) { |
| el17arm | 2:725c213b2396 | 63 | lcd.drawSprite(_x,_y,12,5,(int *)miner_left); |
| el17arm | 0:fe19852199d2 | 64 | } |
| el17arm | 0:fe19852199d2 | 65 | } |