Matis Requis 201241242

Dependencies:   mbed

Tempest Game

Game Screen

https://os.mbed.com/media/uploads/MatisRequis/tempest_board_wiki.png The board is made of 12 columns. The Hero stays at the top of the column

Game Controls

https://os.mbed.com/media/uploads/MatisRequis/gamepad_buttons.png

To control the hero spaceship point the joystick to the column you want the hero to go to.

Press the A button to shoot a bullet in the column you are currently in.

Revision:
2:d59a92e65bd9
Child:
4:8e3ba8d6d915
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hero/Hero.cpp	Tue May 19 10:18:06 2020 +0000
@@ -0,0 +1,147 @@
+#include "Hero.h"
+
+Hero::Hero() {
+
+}
+
+Hero::~Hero() {
+
+}
+
+void Hero::init(int column) {
+    _column = column;
+}
+    
+void Hero::draw(N5110 &lcd) {
+    Vector2D xypos = getxy();
+    
+    _x = xypos.x;
+    _y = xypos.y;
+    
+    if (_column < 3 && _column >= 0) {
+        lcd.drawRect(_x+4, _y, 6, 2, FILL_BLACK);
+        lcd.drawLine(_x+2, _y+1, _x+12, _y+1, 1);
+        lcd.drawLine(_x+2, _y+3, _x+3, _y+5, 1);
+        lcd.drawLine(_x+12, _y+3, _x+11, _y+5, 1);
+        
+    } else if (_column < 6 && _column > 2) {
+        lcd.drawRect(_x-2, _y+4, 2, 6, FILL_BLACK);
+        
+    } else if (_column < 9 && _column > 5) {
+        //lcd.drawRect();
+        
+    } else {
+        //lcd.drawRect(); 
+    }
+}
+
+void Hero::update(Direction d) {
+    if (_column < 3 && _column >= 0) {
+        
+        if (d == W) {
+            if (_column == 0) {
+                _column = 11;
+            } else {
+                _column--;
+            }
+        } else if (d == E) {
+            if (_column == 11) {
+                _column = 0;
+            } else {
+                _column++;
+            }
+        }
+        
+        
+    } else if (_column < 6 && _column > 2) {
+        if (d == N) {
+            if (_column == 0) {
+                _column = 11;
+            } else {
+                _column--;
+            }
+        } else if (d == S) {
+            if (_column == 11) {
+                _column = 0;
+            } else {
+                _column++;
+            }
+        }
+        
+        
+    } else if (_column < 9 && _column > 5) {
+        if (d == E) {
+            if (_column == 0) {
+                _column = 11;
+            } else {
+                _column--;
+            }
+        } else if (d == W) {
+            if (_column == 11) {
+                _column = 0;
+            } else {
+                _column++;
+            }
+        }
+        
+
+    } else {
+        if (d == S) {
+            if (_column == 0) {
+                _column = 11;
+            } else {
+                _column--;
+            }
+        } else if (d == N) {
+            if (_column == 11) {
+                _column = 0;
+            } else {
+                _column++;
+            }
+        }
+        
+
+    }
+}
+
+Vector2D Hero::getxy() {
+    if (_column == 0) {
+        Vector2D p = {21, 1};
+        return p;   
+    } else if (_column == 1) {
+        Vector2D p = {35, 1};
+        return p;   
+    } else if (_column == 2) {
+        Vector2D p = {49, 1};
+        return p;   
+    } else if (_column == 3) {
+        Vector2D p = {65, 3};
+        return p;   
+    } else if (_column == 4) {
+        Vector2D p = {65, 17};
+        return p;   
+    } else if (_column == 5) {
+        Vector2D p = {65, 31};
+        return p;   
+    } else if (_column == 6) {
+        Vector2D p = {63, 47};
+        return p;   
+    } else if (_column == 7) {
+        Vector2D p = {49, 47};
+        return p;   
+    } else if (_column == 8) {
+        Vector2D p = {35, 47};
+        return p;   
+    } else if (_column == 9) {
+        Vector2D p = {19, 45};
+        return p;   
+    } else if (_column == 10) {
+        Vector2D p = {19, 31};
+        return p;   
+    } else if (_column == 11) {
+        Vector2D p = {19, 17};
+        return p;
+    }
+    Vector2D p = {0,0};
+    return p; 
+}
\ No newline at end of file