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: Miner/Miner.cpp
- Revision:
- 32:5dc769ba4a58
- Parent:
- 30:6d6b48fe3679
diff -r 6d6b48fe3679 -r 5dc769ba4a58 Miner/Miner.cpp
--- a/Miner/Miner.cpp Wed Apr 10 14:29:14 2019 +0000
+++ b/Miner/Miner.cpp Wed Apr 10 17:19:51 2019 +0000
@@ -4,6 +4,11 @@
{
_enem.eflag[0] = false;
_j_flag = false;
+ _k.key[0] = false;
+ _k.key[1] = false;
+ _k.key[2] = false;
+ _k.key[3] = false;
+ _k.key[4] = false;
}
Miner::~Miner()
@@ -122,4 +127,62 @@
} else {
return false;
}
+}
+
+void Miner::key_collect(int k, int x, int y, N5110 &lcd, Gamepad &pad)
+{
+ if(_k.key[k] == false) {
+ lcd.drawSprite(x,y,3,4,(int *)key);
+ }
+
+ if ((lcd.getPixel(x-1,y+2) || lcd.getPixel(x+2,y-1) || lcd.getPixel(x+4,y+1)) &&
+ _k.key[k] == false) {
+ _keys++;
+ pad.tone(850,0.1);
+ lcd.drawSprite(x,y,3,4,(int *)key_collected);
+ _k.key[k]= true;
+ }
+}
+
+int Miner::keys_collected()
+{
+ int k = _keys;
+ return k;
+}
+
+bool Miner::exit_level(int x, int y, N5110 &lcd)
+{
+ lcd.drawSprite(x,y,6,5,(int *)door);
+
+ if(_keys == 5 && lcd.getPixel(x-1, y+5)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool Miner::trap(int x, int y, N5110 &lcd)
+{
+ lcd.drawSprite(x,y,3,3,(int *)spike);
+
+ if (lcd.getPixel(x,y-1) || lcd.getPixel(x+2,y-1)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void Miner::draw_solid_block(int x, int y, N5110 &lcd)
+{
+ lcd.drawSprite(x,y,3,3,(int *)solid_block);
+ lcd.drawSprite(x,y,3,3,(int *)solid_block);
+}
+
+void Miner::soft_blocks(int x, int y, N5110 &lcd)
+{
+ if(lcd.getPixel(x,y) || lcd.getPixel(x+2,y) || lcd.getPixel(x+4,y)) {
+ lcd.drawRect(x,y+1,6,1,FILL_WHITE);
+ } else {
+ lcd.drawRect(x,y+1,6,1,FILL_BLACK);
+ }
}
\ No newline at end of file