Dependencies:   mbed FATFileSystem

Revision:
20:01efa2bce75d
Parent:
19:065207c07c3c
Child:
21:f3b0ce18b44f
--- a/SceneCreator/SceneCreator.cpp	Wed May 08 02:45:11 2019 +0000
+++ b/SceneCreator/SceneCreator.cpp	Wed May 08 15:48:44 2019 +0000
@@ -22,16 +22,15 @@
 //Primary Function
 void SceneCreator::Scenesp(Bitmap &lcd, CaMove &CM,short int spl,short int spx,short int spy, Direction spd, int rng,WDplayer &wav) {
     this->setup(lcd,CM,spl,spx,spy,spd,wav);
-    this->set_sreg(CM,spl);
-    bool p[6] = {true,true,true,true,true,true};  //Array to allow Pos Events to disable or enable Pre Events
-    while(!dead && CM.in_screen()) {
+    while(!dead && CM.in_screen()) {  //Main Loop exit if charater dead or leaves screen
         dynatime.start();
         lcd.clear();
+        //reload WDplayer data then Load map data
         wav.ISRpreload();
         lcd.renderBMP(SCN[spl],0,0);
-        this->Core_1(lcd, CM,spl,rng,p);  //CORE_1 (Pre Events Engine)
+        this->Core_1(lcd, CM,spl,rng,p);
         this->update_charaters(lcd,CM,spl,wav);
-        this->Core_2(lcd, CM,spl,rng,p,wav);  //CORE_2 (Pos Event Engine)
+        this->Core_2(lcd, CM,spl,rng,p,wav);
         if (CM.is_caught()) {
             dead = true;
         }
@@ -42,7 +41,7 @@
     CM.delete_regions();
 };
 
-void SceneCreator::update_charaters(Bitmap &lcd,CaMove &CM,short int spl,WDplayer &wav) {
+void SceneCreator::update_charaters(Bitmap &lcd, CaMove &CM,short int spl, WDplayer &wav) {
     //Charater and Chaser Model Update
     CM.move(lcd);
     CM.chase(lcd,spl);
@@ -50,27 +49,32 @@
 }
 
 void SceneCreator::dynamic_wait() {
-    //Will aim for 7 frames per second if too heavy of performance impacting frame rate will drop
-    dynatime.stop();
-    float waittime = 0.15f - dynatime.read();
-    if (waittime > 0.00000f) {
-        wait(waittime);
-    }
-    dynatime.reset();
+   dynatime.stop();
+        float waittime = 0.15f - dynatime.read();
+        if (waittime > 0.00000f) {
+            wait(waittime);
+        }
+        dynatime.reset();
+        //Will aim for 7 frames per second if too heavy of performance impacting frame rate will drop 
 }
 
-void SceneCreator::setup(Bitmap &lcd,CaMove &CM,short int spl,short int spx,short int spy, Direction spd,WDplayer &wav) {
+void SceneCreator::setup(Bitmap &lcd, CaMove &CM,short int spl,short int spx,short int spy, Direction spd, WDplayer &wav) {
     //Setting up WDplayer, CaMove and Scene interative regions
     wav.ISRset();
     CM.init(spx,spy,spd);
     CM.AIinit(spl);
     lcd.normalMode();
     this->set_sreg(CM,spl);
+    //Array to allow Pos Events to disable or enable Pre Events
+    p[0] = true;
+    p[1] = true;
+    p[2] = true;
+    p[3] = true;
+    p[4] = true;
 }
 
-
 //CORE_1 (Pre EVENTS)
-void SceneCreator::Core_1(Bitmap &lcd, CaMove &CM,short int spl,int rng,bool p[6]) {
+void SceneCreator::Core_1(Bitmap &lcd, CaMove &CM,short int spl,int rng,bool p[5]) {
     if (p[0]) {
             this->pre_func0(spl,lcd,CM,rng);
         }
@@ -89,33 +93,33 @@
 }
 
 //CORE_2 (Pos EVENTs)
-void SceneCreator::Core_2(Bitmap &lcd, CaMove &CM,short int spl,int rng,bool (&p)[6],WDplayer &wav) {
-    switch(CM.get_treg()) {  //Checks which region triggered
+void SceneCreator::Core_2(Bitmap &lcd, CaMove &CM,short int spl,int rng,bool (&p)[5],WDplayer &wav) {
+    switch(CM.get_treg()) {     //Checks which region triggered
             case 0:
-                this->onetimeflash(p[0],wav,lcd);
+                this->task_completed(p[0] ,lcd ,wav);
                 this->pos_func0(spl,lcd,CM,rng);
-            break;
+                break;
             case 1:
-                this->onetimeflash(p[1],wav,lcd);
+                this->task_completed(p[1] ,lcd ,wav);
                 this->pos_func1(spl,lcd,CM,rng);
             break;
             case 2:
-                this->onetimeflash(p[2],wav,lcd);
+                this->task_completed(p[2] ,lcd ,wav);
                 this->pos_func2(spl,lcd,CM,rng);
             break;
             case 3:
-                this->onetimeflash(p[3],wav,lcd);
+                this->task_completed(p[3] ,lcd ,wav);
                 this->pos_func3(spl,lcd,CM,rng);
             break;
             case 4:
-                this->onetimeflash(p[4],wav,lcd);
+                this->task_completed(p[4] ,lcd ,wav);
                 this->pos_func4(spl,lcd,CM,rng);
-            break;
+            break;     
         };
         wav.ISRresume();
 }
 
-void SceneCreator::onetimeflash(bool uno, WDplayer &wav,Bitmap &lcd) {
+void SceneCreator::task_completed(bool &uno, Bitmap &lcd, WDplayer &wav) {
     wav.ISRpause();
     if(uno) {
         uno *= false;
@@ -234,6 +238,20 @@
     }
 }
 
+void SceneCreator::pre_func5(int sce,Bitmap &lcd,CaMove &CM,int rng) {
+    switch(sce) {
+        case 0:
+        break;
+        case 1:
+        break;
+        case 2:
+        break;
+        case 3:
+        break;
+        case 4:
+        break;
+    }
+}
 //pos func
 
 void SceneCreator::pos_func0(int sce,Bitmap &lcd,CaMove &CM,int rng) {
@@ -322,6 +340,21 @@
     }
 }
 
+void SceneCreator::pos_func5(int sce,Bitmap &lcd,CaMove &CM,int rng) {
+    switch(sce) {
+        case 0:
+        break;
+        case 1:
+        break;
+        case 2:
+        break;
+        case 3:
+        break;
+        case 4:
+        break;
+    }
+}
+
 bool SceneCreator::get_dead() {
     return dead;
 }