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@1:813ba5341985, 2019-03-19 (annotated)
- Committer:
- el17arm
- Date:
- Tue Mar 19 14:48:40 2019 +0000
- Revision:
- 1:813ba5341985
- Parent:
- 0:fe19852199d2
- Child:
- 2:725c213b2396
minerengine class working fine, jumping and moving. Next will build new class to build environment for character.
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 | 0:fe19852199d2 | 4 | { |
| el17arm | 0:fe19852199d2 | 5 | } |
| el17arm | 0:fe19852199d2 | 6 | |
| el17arm | 1:813ba5341985 | 7 | Minerengine::~Minerengine() |
| el17arm | 0:fe19852199d2 | 8 | { |
| el17arm | 1:813ba5341985 | 9 | } |
| el17arm | 0:fe19852199d2 | 10 | |
| el17arm | 1:813ba5341985 | 11 | void Minerengine::read_direction(Gamepad &pad) |
| el17arm | 1:813ba5341985 | 12 | { |
| el17arm | 1:813ba5341985 | 13 | _d = pad.get_direction(); |
| el17arm | 1:813ba5341985 | 14 | printf("direction %i \n", _d); |
| el17arm | 1:813ba5341985 | 15 | } |
| el17arm | 0:fe19852199d2 | 16 | |
| el17arm | 1:813ba5341985 | 17 | void Minerengine::miner_move() |
| el17arm | 1:813ba5341985 | 18 | { |
| el17arm | 1:813ba5341985 | 19 | if (_d==3) { |
| el17arm | 1:813ba5341985 | 20 | _x = _x + 1; |
| el17arm | 1:813ba5341985 | 21 | _direction = 1; |
| el17arm | 0:fe19852199d2 | 22 | } |
| el17arm | 1:813ba5341985 | 23 | if (_d==7) { |
| el17arm | 1:813ba5341985 | 24 | _x = _x - 1; |
| el17arm | 1:813ba5341985 | 25 | _direction = 0; |
| el17arm | 1:813ba5341985 | 26 | } |
| el17arm | 1:813ba5341985 | 27 | printf(" x = %i \n", _x); |
| el17arm | 1:813ba5341985 | 28 | } |
| el17arm | 0:fe19852199d2 | 29 | |
| el17arm | 1:813ba5341985 | 30 | void Minerengine::miner_jump(N5110 &lcd, Gamepad &pad) |
| el17arm | 1:813ba5341985 | 31 | { |
| el17arm | 1:813ba5341985 | 32 | if(_d==3 && pad.check_event(Gamepad::A_PRESSED)) { |
| el17arm | 1:813ba5341985 | 33 | for (int i = 0; i < 6; i++){ |
| el17arm | 1:813ba5341985 | 34 | _y = _y -1; |
| el17arm | 1:813ba5341985 | 35 | lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_right); |
| el17arm | 1:813ba5341985 | 36 | |
| el17arm | 1:813ba5341985 | 37 | } |
| el17arm | 0:fe19852199d2 | 38 | } |
| el17arm | 1:813ba5341985 | 39 | if(_d==7 && pad.check_event(Gamepad::A_PRESSED)) |
| el17arm | 1:813ba5341985 | 40 | { |
| el17arm | 1:813ba5341985 | 41 | for (int i = 0; i < 6; i++) |
| el17arm | 1:813ba5341985 | 42 | { |
| el17arm | 1:813ba5341985 | 43 | _y = _y -1; |
| el17arm | 1:813ba5341985 | 44 | lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_left); |
| el17arm | 1:813ba5341985 | 45 | |
| el17arm | 1:813ba5341985 | 46 | } |
| el17arm | 1:813ba5341985 | 47 | } |
| el17arm | 1:813ba5341985 | 48 | } |
| el17arm | 0:fe19852199d2 | 49 | |
| el17arm | 1:813ba5341985 | 50 | void Minerengine::miner_draw(N5110 &lcd) |
| el17arm | 1:813ba5341985 | 51 | { |
| el17arm | 1:813ba5341985 | 52 | if (_direction == 1) |
| el17arm | 1:813ba5341985 | 53 | { |
| el17arm | 1:813ba5341985 | 54 | lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_right); |
| el17arm | 1:813ba5341985 | 55 | } |
| el17arm | 1:813ba5341985 | 56 | if (_direction == 0) |
| el17arm | 1:813ba5341985 | 57 | { |
| el17arm | 1:813ba5341985 | 58 | lcd.drawSprite(WIDTH/2 + _x,HEIGHT/2 + _y,13,5,(int *)miner_left); |
| el17arm | 0:fe19852199d2 | 59 | } |
| el17arm | 0:fe19852199d2 | 60 | } |