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@0:fe19852199d2, 2019-03-19 (annotated)
- Committer:
- el17arm
- Date:
- Tue Mar 19 09:49:12 2019 +0000
- Revision:
- 0:fe19852199d2
- Child:
- 1:813ba5341985
minerengine class working, will now break up minermove() into seperate functions as currently too bloated
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 | 0:fe19852199d2 | 7 | void Minerengine::minermove(N5110 &lcd, Gamepad &pad) |
| el17arm | 0:fe19852199d2 | 8 | { |
| el17arm | 0:fe19852199d2 | 9 | |
| el17arm | 0:fe19852199d2 | 10 | printf("hello world /n"); |
| el17arm | 0:fe19852199d2 | 11 | lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); |
| el17arm | 0:fe19852199d2 | 12 | |
| el17arm | 0:fe19852199d2 | 13 | Direction d = pad.get_direction(); |
| el17arm | 0:fe19852199d2 | 14 | printf("Direction = %i\n",d); |
| el17arm | 0:fe19852199d2 | 15 | |
| el17arm | 0:fe19852199d2 | 16 | if (d==3) { |
| el17arm | 0:fe19852199d2 | 17 | |
| el17arm | 0:fe19852199d2 | 18 | x_direction = x_direction + 1; |
| el17arm | 0:fe19852199d2 | 19 | lcd.clear(); |
| el17arm | 0:fe19852199d2 | 20 | lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); |
| el17arm | 0:fe19852199d2 | 21 | lcd.refresh(); |
| el17arm | 0:fe19852199d2 | 22 | wait(0.05); |
| el17arm | 0:fe19852199d2 | 23 | } |
| el17arm | 0:fe19852199d2 | 24 | |
| el17arm | 0:fe19852199d2 | 25 | if (d == 7) { |
| el17arm | 0:fe19852199d2 | 26 | |
| el17arm | 0:fe19852199d2 | 27 | x_direction = x_direction - 1; |
| el17arm | 0:fe19852199d2 | 28 | lcd.clear(); |
| el17arm | 0:fe19852199d2 | 29 | lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_left); |
| el17arm | 0:fe19852199d2 | 30 | lcd.refresh(); |
| el17arm | 0:fe19852199d2 | 31 | wait(0.05); |
| el17arm | 0:fe19852199d2 | 32 | } |
| el17arm | 0:fe19852199d2 | 33 | //lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner); |
| el17arm | 0:fe19852199d2 | 34 | lcd.refresh(); |
| el17arm | 0:fe19852199d2 | 35 | |
| el17arm | 0:fe19852199d2 | 36 | if(pad.check_event(Gamepad::A_PRESSED)) { |
| el17arm | 0:fe19852199d2 | 37 | |
| el17arm | 0:fe19852199d2 | 38 | |
| el17arm | 0:fe19852199d2 | 39 | printf("A pressed"); |
| el17arm | 0:fe19852199d2 | 40 | y_direction = y_direction - 6; |
| el17arm | 0:fe19852199d2 | 41 | lcd.clear(); |
| el17arm | 0:fe19852199d2 | 42 | lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right); |
| el17arm | 0:fe19852199d2 | 43 | wait(0.2); |
| el17arm | 0:fe19852199d2 | 44 | y_direction = y_direction + 6; |
| el17arm | 0:fe19852199d2 | 45 | |
| el17arm | 0:fe19852199d2 | 46 | } |
| el17arm | 0:fe19852199d2 | 47 | } |