ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Revision:
18:304700b5d8f8
Parent:
16:331be5c7ed80
Child:
21:20478f086bc2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fire/Fire.cpp	Fri Apr 12 11:30:25 2019 +0000
@@ -0,0 +1,54 @@
+#include "Fire.h"
+
+// Define sprite arrays.
+int fire_one[5][8] = {
+  { 1,0,1,0,0,1,0,0 },
+  { 1,0,0,0,1,1,1,0 },
+  { 0,0,0,1,1,1,1,1 },
+  { 0,1,0,0,1,1,1,0 },
+  { 1,0,0,1,0,1,0,0 },
+};
+
+int fire_two[5][8] = {
+  { 0,0,1,0,0,1,0,0 },
+  { 0,1,0,0,1,1,1,0 },
+  { 1,0,1,0,1,1,1,0 },
+  { 1,0,0,0,1,1,1,0 },
+  { 0,1,0,1,1,0,0,0 },
+};
+
+// Constructor and destructor.
+Fire::Fire() {} 
+
+Fire::~Fire() {}
+
+void Fire::init() {
+  // Initialise the fire ball
+  _x = -10;
+  _fire_counter = false;
+}
+
+void Fire::update_fire() {
+  // On every iteration move the fire horizontally and toggle the fire counter.
+  // If the fire goes off the screen, restart it on the other side.
+  _x++;
+  _fire_counter = !_fire_counter;
+  if (_x == 90) _x = -10;
+}
+
+int * Fire::get_fire_sprite() {
+  // Return a different fire sprite on each iteration.
+  if (_fire_counter) {
+    return *fire_one;
+  } else {
+    return *fire_two;
+  }
+}
+  
+int Fire::get_fire_x() {
+  return _x;
+}
+
+
+
+