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: Level1/Level1.cpp
- Revision:
- 26:bce40bf4c9fc
- Parent:
- 24:9c7aca60e374
- Child:
- 27:e73dd64ef334
--- a/Level1/Level1.cpp Mon Apr 08 18:17:10 2019 +0000
+++ b/Level1/Level1.cpp Tue Apr 09 01:36:47 2019 +0000
@@ -11,9 +11,9 @@
void Level1::level_platforms(N5110 &lcd)
{
lcd.drawLine(0,47,83,47, 1);
- lcd.drawRect(11,HEIGHT - 9, 38, 2, FILL_BLACK);
- lcd.drawRect(65,HEIGHT - 11, 30, 2, FILL_BLACK);
- lcd.drawRect(WIDTH - 9,HEIGHT - 19, 8, 2, FILL_BLACK);
+ lcd.drawRect(11,39, 38, 2, FILL_BLACK);
+ lcd.drawRect(65,37, 30, 2, FILL_BLACK);
+ lcd.drawRect(75,29, 8, 2, FILL_BLACK);
lcd.drawRect(22, 25, 48, 2, FILL_BLACK);
lcd.drawRect(0, 25, 12, 2, FILL_BLACK);
lcd.drawRect(0, 17, 8, 2, FILL_BLACK);
@@ -48,13 +48,13 @@
_level.key_collect(2, 40, 6, lcd, pad);
_level.key_collect(3, 62, 6, lcd, pad);
_level.key_collect(4, 75, 0, lcd, pad);
-
+
}
-int Level1::spikes(N5110 &lcd)
+int Level1::traps(N5110 &lcd)
{
- if(_level.spike1(25, 45, lcd) || _level.spike1(58, 7, lcd) ||
- _level.spike3(75, 7, lcd) || _level.spike4(23,7,lcd)) {
+ if(_level.trap(25, 45, lcd) || _level.trap(58, 7, lcd) ||
+ _level.trap(75, 7, lcd) || _level.trap(23,7,lcd)) {
return 1;
} else {
return 0;
@@ -69,9 +69,41 @@
bool Level1::level1_exit(N5110 &lcd)
{
- if(_level.exit(78,41,lcd) == true) {
+ if(_level.exit_level(78,41,lcd) == true) {
return true;
} else {
return false;
}
-}
\ No newline at end of file
+}
+
+void Level1::enemy_init(int x, int y, int d)
+{
+ _x = x;
+ _y = y;
+ _d = d;
+
+}
+
+void Level1::enemies_right(N5110 &lcd)
+{
+ lcd.drawSprite(_x,_y,5,3, (int *) enemy);
+ if (lcd.getPixel(_x+3,_y+4) == 0 && _d == 0) {
+ _x = _x + 0.25;
+ }
+ if (lcd.getPixel(_x+3,_y+4) == 1) {
+ _d = 1;
+ }
+}
+
+void Level1::enemies_left(N5110 &lcd)
+{
+ if (_d == 1 && lcd.getPixel(_x, _y +5) == 1) {
+ _x = _x - 0.25;
+ }
+ if (lcd.getPixel(_x,_y+5) == 0) {
+ _d = 0;
+ }
+ printf("_d = %i \n", _d);
+ printf("pixel = %i \n", lcd.getPixel(_x+3,_y+5));
+}
+