Game for Leeds University Gamepad for the FRDM-K64F: Game is a RPG Horror Title.
Dependencies: mbed FATFileSystem
Diff: SceneCreator/SceneCreator.cpp
- Revision:
- 21:f3b0ce18b44f
- Parent:
- 20:01efa2bce75d
- Child:
- 26:716bcd47f3ca
--- a/SceneCreator/SceneCreator.cpp Wed May 08 15:48:44 2019 +0000 +++ b/SceneCreator/SceneCreator.cpp Thu May 09 06:22:53 2019 +0000 @@ -10,8 +10,7 @@ //Constructor SceneCreator::SceneCreator(PinName Button) { this->set_buttonPin(Button); - dead = false; - + dead = false; } //Destructor @@ -25,38 +24,23 @@ 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); + lcd.renderBMP(SCN[spl],0,0); //Map Made + this->Core_1(lcd, CM,spl,rng,p); //Pre - Events this->update_charaters(lcd,CM,spl,wav); - this->Core_2(lcd, CM,spl,rng,p,wav); + this->Core_2(lcd, CM,spl,rng,p,wav); //Pos - Events if (CM.is_caught()) { dead = true; } lcd.refresh(); this->dynamic_wait(); }; - wav.ISRreset(); + wav.ISRreset(); //Clear Scene data CM.delete_regions(); }; -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); - wav.ISRpreload(); -} -void SceneCreator::dynamic_wait() { - 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 -} +//Internal Functions for Scenesp 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 @@ -65,7 +49,8 @@ CM.AIinit(spl); lcd.normalMode(); this->set_sreg(CM,spl); - //Array to allow Pos Events to disable or enable Pre Events + this->reset_variables(); + //Array to allow Pos Events to disable or enable Pre Events (Resetting) p[0] = true; p[1] = true; p[2] = true; @@ -73,7 +58,8 @@ p[4] = true; } -//CORE_1 (Pre EVENTS) + +//CORE_1 (Pre EVENTS) 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); @@ -97,7 +83,7 @@ switch(CM.get_treg()) { //Checks which region triggered case 0: this->task_completed(p[0] ,lcd ,wav); - this->pos_func0(spl,lcd,CM,rng); + this->pos_func0(spl,lcd,CM,rng,wav); break; case 1: this->task_completed(p[1] ,lcd ,wav); @@ -119,6 +105,25 @@ wav.ISRresume(); } +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); + wav.ISRpreload(); +} + +void SceneCreator::dynamic_wait() { + 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 +} + +//Aiding Functions - used in Core 2 + void SceneCreator::task_completed(bool &uno, Bitmap &lcd, WDplayer &wav) { wav.ISRpause(); if(uno) { @@ -127,6 +132,7 @@ } } + //settings //All below Functions Check which scene is operating and then fetches the required Function from SceneFunctions //They all are they same... @@ -238,23 +244,9 @@ } } -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) { +void SceneCreator::pos_func0(int sce,Bitmap &lcd,CaMove &CM,int rng,WDplayer &wav) { switch(sce) { case 0: this->event0_scene0(lcd); @@ -263,13 +255,13 @@ this->event0_scene1(lcd); break; case 2: - this->event0_scene2(lcd,CM); + this->event0_scene2(lcd,CM,wav); break; case 3: this->event0_scene3(lcd); break; case 4: - this->event0_scene4(lcd,CM); + this->event0_scene4(lcd,CM,wav); break; } } @@ -340,20 +332,7 @@ } } -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; - } -} +//Accessors and Mutators and other Small Functions bool SceneCreator::get_dead() { return dead; @@ -362,3 +341,8 @@ void SceneCreator::set_dead(bool opt) { dead = opt; } + + +void SceneCreator::flashy(Bitmap &lcd) { + this->flash(lcd); +}