Mortal Kombat Game ELEC2645

Dependencies:   mbed N5110 ShiftReg Joystick

Revision:
8:e2e2eb4ea0ca
Parent:
7:737fb0c3dbef
Child:
10:e83899f11e8a
--- a/Enemy.cpp	Thu Apr 22 01:24:12 2021 +0000
+++ b/Enemy.cpp	Thu Apr 22 18:33:23 2021 +0000
@@ -27,30 +27,48 @@
     _y += y;
 }
 
-void Enemy::init(N5110 &lcd) {
-    set_x(30);
+void Enemy::init() {
+    set_x(50);
     set_y(34);
-    draw(lcd);
-    lcd.refresh();
 }
-void Enemy::draw(N5110 &lcd) {
+void Enemy::draw(N5110 &lcd, int input) {
 
-    const int standsprite[12][10] =   {
-    { 0,0,0,0,1,1,0,0,0,0 },
-    { 0,0,0,0,1,1,0,0,0,0 },
-    { 0,0,1,1,1,1,1,1,1,0 },
-    { 0,1,0,0,1,1,0,0,1,0 },
-    { 0,1,0,0,1,1,0,1,1,1 },
+    const int look_left[12][10] =   {
+    { 0,0,1,1,1,0,0,0,0,0 },
+    { 0,0,1,1,1,0,0,0,0,0 },
+    { 0,0,0,1,1,1,1,1,1,0 },
+    { 0,0,1,0,1,1,0,0,1,0 },
+    { 1,1,1,0,1,1,0,1,1,1 },
     { 0,0,0,0,1,1,0,0,1,0 },
     { 0,0,0,1,1,1,1,0,0,0 },
     { 0,0,1,1,0,0,1,1,0,0 },
-    { 0,0,1,0,0,0,0,1,0,0 },
-    { 0,1,1,0,0,0,0,1,1,0 },
-    { 0,1,0,0,0,0,0,0,1,0 },
-    { 0,1,0,0,0,0,0,0,1,0 },
+    { 0,1,1,0,0,0,1,1,0,0 },
+    { 0,0,1,1,0,0,0,1,1,0 },
+    { 0,0,0,1,0,0,0,0,1,0 },
+    { 0,1,1,1,0,0,0,1,1,0 },
     };
 
-lcd.drawSprite(_x,_y,12,10,(int *)standsprite);
+    const int look_right[12][10] =   {
+    { 0,0,0,0,0,1,1,1,0,0 },
+    { 0,0,0,0,0,1,1,1,0,0 },
+    { 0,0,0,1,1,1,1,0,0,0 },
+    { 0,0,1,1,1,1,1,0,1,0 },
+    { 0,1,1,0,1,1,0,1,1,1 },
+    { 0,0,0,0,1,1,0,0,1,0 },
+    { 0,0,0,1,1,1,1,0,0,0 },
+    { 0,0,1,1,0,0,1,1,0,0 },
+    { 0,0,1,1,0,0,0,1,1,0 },
+    { 0,1,1,0,0,0,1,1,0,0 },
+    { 0,1,0,0,0,1,1,0,0,0 },
+    { 0,1,1,0,1,1,1,1,0,0 },
+    };
+
+    if (input == 1) {
+        lcd.drawSprite(_x,_y,12,10,(int *)look_right);
+        }
+    else {
+        lcd.drawSprite(_x,_y,12,10,(int *)look_left);
+        }
 }
 // ************************************************************************