Dependencies:   mbed FATFileSystem

Committer:
rottenegg
Date:
Fri Apr 26 02:31:11 2019 +0000
Revision:
10:4fda7b01484a
Parent:
9:ac396c818874
Child:
13:95323e0f2fcb
CaMove: Added Additional Chaser Character Model.; SceneCreator: Added RNG input to cause Minor Changes.; SceneFunctions: Added Scene 2, 3 Functions.; Ready For Main GAME MANAGER...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rottenegg 9:ac396c818874 1 #include "SceneFunctions.h"
rottenegg 10:4fda7b01484a 2 #include "MiscPaths.h"
rottenegg 9:ac396c818874 3
rottenegg 9:ac396c818874 4 //Constructor Functions
rottenegg 9:ac396c818874 5 void SceneFunctions::set_buttonPin(PinName pin) {
rottenegg 9:ac396c818874 6 _BOK = (new DigitalIn(pin));
rottenegg 9:ac396c818874 7 _BOK->mode(PullDown);
rottenegg 10:4fda7b01484a 8 _progress = 0;
rottenegg 10:4fda7b01484a 9 _p[0] = true;
rottenegg 10:4fda7b01484a 10 _p[1] = true;
rottenegg 10:4fda7b01484a 11 _p[2] = true;
rottenegg 9:ac396c818874 12 }
rottenegg 9:ac396c818874 13
rottenegg 9:ac396c818874 14 void SceneFunctions::deletebutton() {
rottenegg 9:ac396c818874 15 delete _BOK;
rottenegg 9:ac396c818874 16 }
rottenegg 9:ac396c818874 17
rottenegg 9:ac396c818874 18 //Ultility Functions
rottenegg 9:ac396c818874 19 void SceneFunctions::transition(N5110 &lcd) {
rottenegg 9:ac396c818874 20 for (int i = 0;i < 84;i++) {
rottenegg 9:ac396c818874 21 lcd.drawRect(0,0,i,48,FILL_BLACK);
rottenegg 9:ac396c818874 22 lcd.refresh();
rottenegg 9:ac396c818874 23 }
rottenegg 9:ac396c818874 24 for (int i = 0;i < 84;i++) {
rottenegg 9:ac396c818874 25 lcd.drawRect(0,0,i,48,FILL_WHITE);
rottenegg 9:ac396c818874 26 lcd.refresh();
rottenegg 9:ac396c818874 27 }
rottenegg 9:ac396c818874 28 }
rottenegg 9:ac396c818874 29
rottenegg 9:ac396c818874 30 void SceneFunctions::lockin(N5110 &lcd) {
rottenegg 9:ac396c818874 31 while (_BOK->read() == 0) {
rottenegg 9:ac396c818874 32 lcd.printString(" ",0,5);
rottenegg 9:ac396c818874 33 lcd.refresh();
rottenegg 9:ac396c818874 34 wait(0.15);
rottenegg 9:ac396c818874 35 lcd.printString("...Press B...",0,5);
rottenegg 9:ac396c818874 36 lcd.refresh();
rottenegg 9:ac396c818874 37 wait(0.15);
rottenegg 9:ac396c818874 38 }
rottenegg 9:ac396c818874 39 }
rottenegg 9:ac396c818874 40
rottenegg 9:ac396c818874 41 void SceneFunctions::flash(N5110 &lcd) {
rottenegg 9:ac396c818874 42 for(int i = 0; i < 4; i++) {
rottenegg 9:ac396c818874 43 lcd.drawRect(0,0,84,48,FILL_BLACK);
rottenegg 9:ac396c818874 44 lcd.refresh();
rottenegg 9:ac396c818874 45 wait(0.15);
rottenegg 9:ac396c818874 46 lcd.drawRect(0,0,84,48,FILL_WHITE);
rottenegg 9:ac396c818874 47 lcd.refresh();
rottenegg 9:ac396c818874 48 wait(0.15);
rottenegg 9:ac396c818874 49 };
rottenegg 9:ac396c818874 50 };
rottenegg 9:ac396c818874 51
rottenegg 9:ac396c818874 52 //Unique to Scene Functions
rottenegg 9:ac396c818874 53 //scene 0 Functions
rottenegg 9:ac396c818874 54 void SceneFunctions::set_scene0(CaMove &CM) {
rottenegg 9:ac396c818874 55 CM.set_region(1, 28, 12, 17); //event 0
rottenegg 9:ac396c818874 56 CM.set_region(66, 15, 21, 24); //event 1
rottenegg 9:ac396c818874 57 };
rottenegg 9:ac396c818874 58 //pre funtions
rottenegg 9:ac396c818874 59 void SceneFunctions::obj0_scene0(N5110 &lcd) {
rottenegg 9:ac396c818874 60 lcd.drawRect(32,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 61 };
rottenegg 9:ac396c818874 62 //pos functions
rottenegg 9:ac396c818874 63 void SceneFunctions::event0_scene0(N5110 &lcd) {
rottenegg 9:ac396c818874 64 this->transition(lcd);
rottenegg 9:ac396c818874 65 lcd.clear();
rottenegg 9:ac396c818874 66 lcd.printString("Hello My Name",0,0);
rottenegg 9:ac396c818874 67 lcd.printString("Veigar I Shall",0,1);
rottenegg 9:ac396c818874 68 lcd.printString("Help You Find",0,2);
rottenegg 9:ac396c818874 69 lcd.printString("What You Seek",0,3);
rottenegg 9:ac396c818874 70 lcd.printString("Now go ... ",0,4);
rottenegg 9:ac396c818874 71 lcd.refresh();
rottenegg 9:ac396c818874 72 this->lockin(lcd);
rottenegg 9:ac396c818874 73 this->transition(lcd);
rottenegg 9:ac396c818874 74 }
rottenegg 9:ac396c818874 75
rottenegg 9:ac396c818874 76 //event 1
rottenegg 9:ac396c818874 77 void SceneFunctions::event1_scene0(N5110 &lcd) {
rottenegg 9:ac396c818874 78 this->transition(lcd);
rottenegg 9:ac396c818874 79 lcd.clear();
rottenegg 9:ac396c818874 80 lcd.printString("It's a Weird",0,0);
rottenegg 9:ac396c818874 81 lcd.printString("quite eerie...",0,1);
rottenegg 9:ac396c818874 82 lcd.printString("Statue !!",0,2);
rottenegg 9:ac396c818874 83 lcd.refresh();
rottenegg 9:ac396c818874 84 this->lockin(lcd);
rottenegg 9:ac396c818874 85 this->transition(lcd);
rottenegg 9:ac396c818874 86 }
rottenegg 9:ac396c818874 87
rottenegg 9:ac396c818874 88 //scene1 Funtions
rottenegg 9:ac396c818874 89 void SceneFunctions::set_scene1(CaMove &CM) {
rottenegg 9:ac396c818874 90 CM.set_region(2, 38, 8, 7); //event 0
rottenegg 9:ac396c818874 91 CM.set_region(72, 2, 8, 7); //event 1
rottenegg 9:ac396c818874 92 };
rottenegg 9:ac396c818874 93
rottenegg 9:ac396c818874 94 //pre funtions
rottenegg 9:ac396c818874 95 void SceneFunctions::obj0_scene1(N5110 &lcd) {
rottenegg 9:ac396c818874 96 lcd.drawLine(30,40,31,20,0);
rottenegg 9:ac396c818874 97 lcd.drawLine(55,40,55,20,1);
rottenegg 9:ac396c818874 98 lcd.drawRect(5,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 99 }
rottenegg 9:ac396c818874 100
rottenegg 9:ac396c818874 101 void SceneFunctions::obj1_scene1(N5110 &lcd) {
rottenegg 9:ac396c818874 102 lcd.drawRect(32,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 103 }
rottenegg 9:ac396c818874 104
rottenegg 9:ac396c818874 105
rottenegg 9:ac396c818874 106 //pos functions
rottenegg 9:ac396c818874 107 void SceneFunctions::event0_scene1(N5110 &lcd) {
rottenegg 9:ac396c818874 108 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 109 lcd.drawLine(4,39,7,41,1);
rottenegg 9:ac396c818874 110 lcd.refresh();
rottenegg 9:ac396c818874 111 wait(0.2);
rottenegg 9:ac396c818874 112 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 113 lcd.drawLine(9,39,7,41,1);
rottenegg 9:ac396c818874 114 lcd.refresh();
rottenegg 9:ac396c818874 115 wait(0.2);
rottenegg 9:ac396c818874 116 }
rottenegg 9:ac396c818874 117
rottenegg 9:ac396c818874 118 void SceneFunctions::event1_scene1(N5110 &lcd) {
rottenegg 9:ac396c818874 119 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 120 lcd.drawLine(74,3,77,5,1);
rottenegg 9:ac396c818874 121 lcd.refresh();
rottenegg 9:ac396c818874 122 wait(0.2);
rottenegg 9:ac396c818874 123 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 124 lcd.drawLine(79,3,77,5,1);
rottenegg 9:ac396c818874 125 lcd.refresh();
rottenegg 9:ac396c818874 126 wait(0.2);
rottenegg 9:ac396c818874 127 }
rottenegg 10:4fda7b01484a 128
rottenegg 10:4fda7b01484a 129 //Scene 2 Functions
rottenegg 10:4fda7b01484a 130 void SceneFunctions::set_scene2(CaMove &CM) {
rottenegg 10:4fda7b01484a 131 CM.set_region(9, 17, 10, 14); //event 0
rottenegg 10:4fda7b01484a 132
rottenegg 10:4fda7b01484a 133 };
rottenegg 10:4fda7b01484a 134 //pre Functions
rottenegg 10:4fda7b01484a 135 void SceneFunctions::obj0_scene2(N5110 &lcd) {
rottenegg 10:4fda7b01484a 136 Bitmap::renderBMP(MISC[0],lcd,9,17);
rottenegg 10:4fda7b01484a 137 lcd.drawLine(83,13,83,33,1); //right
rottenegg 10:4fda7b01484a 138 lcd.drawLine(47,0,67,0,1); // top
rottenegg 10:4fda7b01484a 139 lcd.drawLine(47,47,67,47,1); //bot
rottenegg 10:4fda7b01484a 140 }
rottenegg 10:4fda7b01484a 141
rottenegg 10:4fda7b01484a 142 void SceneFunctions::obj1_scene2(N5110 &lcd,int rng) {
rottenegg 10:4fda7b01484a 143 switch(rng) {
rottenegg 10:4fda7b01484a 144 case 0:
rottenegg 10:4fda7b01484a 145 lcd.drawLine(83,13,83,33,1); //r
rottenegg 10:4fda7b01484a 146 lcd.drawLine(47,0,67,0,1); // t
rottenegg 10:4fda7b01484a 147 break;
rottenegg 10:4fda7b01484a 148 case 1:
rottenegg 10:4fda7b01484a 149 lcd.drawLine(47,47,67,47,1); //b
rottenegg 10:4fda7b01484a 150 lcd.drawLine(83,13,83,33,1); //r
rottenegg 10:4fda7b01484a 151 break;
rottenegg 10:4fda7b01484a 152 case 2:
rottenegg 10:4fda7b01484a 153 lcd.drawLine(47,47,67,47,1); //b
rottenegg 10:4fda7b01484a 154 lcd.drawLine(47,0,67,0,1); // t
rottenegg 10:4fda7b01484a 155 break;
rottenegg 10:4fda7b01484a 156 }
rottenegg 10:4fda7b01484a 157 }
rottenegg 10:4fda7b01484a 158
rottenegg 10:4fda7b01484a 159 //pos Function
rottenegg 10:4fda7b01484a 160 void SceneFunctions::event0_scene2(N5110 &lcd,CaMove &CM) {
rottenegg 10:4fda7b01484a 161 this->transition(lcd);
rottenegg 10:4fda7b01484a 162 lcd.clear();
rottenegg 10:4fda7b01484a 163 Bitmap::renderBMP(MISC[1],lcd,0,0);
rottenegg 10:4fda7b01484a 164 lcd.refresh();
rottenegg 10:4fda7b01484a 165 wait(1);
rottenegg 10:4fda7b01484a 166 CM.delete_regions();
rottenegg 10:4fda7b01484a 167 lcd.clear();
rottenegg 10:4fda7b01484a 168 lcd.printString("Help Me Please",0,0);
rottenegg 10:4fda7b01484a 169 lcd.refresh();
rottenegg 10:4fda7b01484a 170 wait(0.5);
rottenegg 10:4fda7b01484a 171 lcd.printString("I NEED YOUR",0,1);
rottenegg 10:4fda7b01484a 172 lcd.printString("BLOOOD !!!",0,2);
rottenegg 10:4fda7b01484a 173 lcd.refresh();
rottenegg 10:4fda7b01484a 174 wait(1);
rottenegg 10:4fda7b01484a 175 CM.init(29,17,Fd);
rottenegg 10:4fda7b01484a 176 CM.spawn(9,17);
rottenegg 10:4fda7b01484a 177 lcd.inverseMode();
rottenegg 10:4fda7b01484a 178 }
rottenegg 10:4fda7b01484a 179
rottenegg 10:4fda7b01484a 180 //Scene 3 Functions
rottenegg 10:4fda7b01484a 181 void SceneFunctions::set_scene3(CaMove &CM) {
rottenegg 10:4fda7b01484a 182 CM.set_region(72, 39, 10, 7); //event 0
rottenegg 10:4fda7b01484a 183 CM.set_region(73, 11, 10, 17); //event 1
rottenegg 10:4fda7b01484a 184 CM.set_region(64, 5, 10, 14); //event 2
rottenegg 10:4fda7b01484a 185 CM.set_region(42, 2, 11, 18); //event 3
rottenegg 10:4fda7b01484a 186 };
rottenegg 10:4fda7b01484a 187
rottenegg 10:4fda7b01484a 188 //pre Functions
rottenegg 10:4fda7b01484a 189 void SceneFunctions::obj0_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 190 lcd.drawLine(76,42,78,40,1);
rottenegg 10:4fda7b01484a 191 lcd.drawRect(74,40,2,3,FILL_WHITE);
rottenegg 10:4fda7b01484a 192 lcd.drawRect(28,29,11,13,FILL_WHITE);
rottenegg 10:4fda7b01484a 193 lcd.drawRect(14,31,9,11,FILL_BLACK);
rottenegg 10:4fda7b01484a 194 lcd.drawLine(16,33,20,33,0);
rottenegg 10:4fda7b01484a 195 lcd.drawLine(20,33,20,37,0);
rottenegg 10:4fda7b01484a 196 lcd.drawLine(20,37,16,37,0);
rottenegg 10:4fda7b01484a 197 }
rottenegg 10:4fda7b01484a 198
rottenegg 10:4fda7b01484a 199 void SceneFunctions::obj1_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 200 lcd.setPixel(77,14,false);
rottenegg 10:4fda7b01484a 201 }
rottenegg 10:4fda7b01484a 202 //obj 2 not required
rottenegg 10:4fda7b01484a 203 void SceneFunctions::obj3_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 204 Bitmap::renderBMP(MISC[2],lcd,21,8);
rottenegg 10:4fda7b01484a 205 }
rottenegg 10:4fda7b01484a 206
rottenegg 10:4fda7b01484a 207 void SceneFunctions::obj4_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 208 if (_progress < 3) {
rottenegg 10:4fda7b01484a 209 lcd.drawRect(55,46,16,2,FILL_BLACK);
rottenegg 10:4fda7b01484a 210 }
rottenegg 10:4fda7b01484a 211 }
rottenegg 10:4fda7b01484a 212
rottenegg 10:4fda7b01484a 213 //pos functions
rottenegg 10:4fda7b01484a 214 void SceneFunctions::event0_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 215 if(_p[0]) {
rottenegg 10:4fda7b01484a 216 _p[0] = false;
rottenegg 10:4fda7b01484a 217 _progress++;
rottenegg 10:4fda7b01484a 218 }
rottenegg 10:4fda7b01484a 219 }
rottenegg 10:4fda7b01484a 220
rottenegg 10:4fda7b01484a 221
rottenegg 10:4fda7b01484a 222 void SceneFunctions::event1_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 223 this->transition(lcd);
rottenegg 10:4fda7b01484a 224 lcd.clear();
rottenegg 10:4fda7b01484a 225 lcd.printString("The Statue",0,0);
rottenegg 10:4fda7b01484a 226 lcd.printString("Looks like a",0,1);
rottenegg 10:4fda7b01484a 227 lcd.printString("Head But Eye",0,2);
rottenegg 10:4fda7b01484a 228 lcd.printString("Missing I Stab",0,3);
rottenegg 10:4fda7b01484a 229 lcd.printString("In a New One.",0,4);
rottenegg 10:4fda7b01484a 230 lcd.refresh();
rottenegg 10:4fda7b01484a 231 if(_p[2]) {
rottenegg 10:4fda7b01484a 232 _p[2] = false;
rottenegg 10:4fda7b01484a 233 _progress++;
rottenegg 10:4fda7b01484a 234 }
rottenegg 10:4fda7b01484a 235 this->lockin(lcd);
rottenegg 10:4fda7b01484a 236 this->transition(lcd);
rottenegg 10:4fda7b01484a 237 }
rottenegg 10:4fda7b01484a 238
rottenegg 10:4fda7b01484a 239
rottenegg 10:4fda7b01484a 240 void SceneFunctions::event2_scene3(N5110 &lcd) {
rottenegg 10:4fda7b01484a 241 this->transition(lcd);
rottenegg 10:4fda7b01484a 242 lcd.clear();
rottenegg 10:4fda7b01484a 243 lcd.printString("Welcome to",0,0);
rottenegg 10:4fda7b01484a 244 lcd.printString("Mirror Room",0,1);
rottenegg 10:4fda7b01484a 245 lcd.printString("But Beware Not",0,2);
rottenegg 10:4fda7b01484a 246 lcd.printString("Touch Sarced",0,3);
rottenegg 10:4fda7b01484a 247 lcd.printString("!!!ITEM!!!",0,4);
rottenegg 10:4fda7b01484a 248 lcd.refresh();
rottenegg 10:4fda7b01484a 249 if(_p[1]) {
rottenegg 10:4fda7b01484a 250 _p[1] = false;
rottenegg 10:4fda7b01484a 251 _progress++;
rottenegg 10:4fda7b01484a 252 }
rottenegg 10:4fda7b01484a 253 this->lockin(lcd);
rottenegg 10:4fda7b01484a 254 this->transition(lcd);
rottenegg 10:4fda7b01484a 255 }
rottenegg 10:4fda7b01484a 256
rottenegg 10:4fda7b01484a 257 void SceneFunctions::event3_scene3(N5110 &lcd,CaMove &CM) {
rottenegg 10:4fda7b01484a 258 this->transition(lcd);
rottenegg 10:4fda7b01484a 259 lcd.clear();
rottenegg 10:4fda7b01484a 260 CM.delete_regions();
rottenegg 10:4fda7b01484a 261 lcd.printString("CURSE YOU",0,0);
rottenegg 10:4fda7b01484a 262 lcd.refresh();
rottenegg 10:4fda7b01484a 263 wait(0.5);
rottenegg 10:4fda7b01484a 264 CM.spawn(21,8);
rottenegg 10:4fda7b01484a 265 lcd.inverseMode();
rottenegg 10:4fda7b01484a 266 }