Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Gamepad N5110
Levels.cpp
00001 #include "mbed.h" 00002 #include "Gamepad.h" 00003 #include "N5110.h" 00004 #include "Levels.h" 00005 00006 00007 00008 // nothing doing in the constructor and destructor 00009 Levels::Levels() 00010 { 00011 00012 } 00013 00014 Levels::~Levels() 00015 { 00016 00017 } 00018 00019 00020 //initializes all variables and pos struct. 00021 Pos Levels::init(Pos pos) 00022 { 00023 00024 pos = init_hoz1(pos); //initialises hoz1 part of struct 00025 pos = init_hoz2(pos); //initialises hoz2 part of struct 00026 pos = init_ver1(pos); //initialises ver1 part of struct 00027 pos = init_ver2(pos); //initialises ver2 part of struct 00028 pos = init_spike(pos); //initialises spike part of struct 00029 00030 init_counter1(); //initialises counter1 00031 init_counter2(); //initialises counter2 00032 00033 return pos; 00034 } 00035 00036 00037 //initializes data for horizontal moving platform 1 00038 Pos Levels::init_hoz1(Pos pos) 00039 { 00040 pos.x = 0; //x cord 00041 pos.y = 0; //y cord 00042 pos.d = 0; //dircection 00043 pos.c = 0; //counter 00044 pos.l = 0; //length 00045 pos.h = 0; //height 00046 00047 return pos; 00048 } 00049 00050 00051 //initializes data for horizontal moving platform 2 00052 Pos Levels::init_hoz2(Pos pos) 00053 { 00054 pos.x2 = 0; //x cord 00055 pos.y2 = 0; //y cord 00056 pos.d2 = 0; //dircection 00057 pos.c2 = 0; //counter 00058 pos.l2 = 0; //length 00059 pos.h2 = 0; //height 00060 00061 return pos; 00062 } 00063 00064 00065 //initializes data for vertical moving platform 1 00066 Pos Levels::init_ver1(Pos pos) 00067 { 00068 pos.vx = 0; //x cord 00069 pos.vy = 0; //y cord 00070 pos.vd = 0; //dircection 00071 pos.vc = 0; //counter 00072 pos.vl = 0; //length 00073 pos.vh = 0; //height 00074 00075 return pos; 00076 } 00077 00078 00079 //initializes data for vertical moving platform 1 00080 Pos Levels::init_ver2(Pos pos) 00081 { 00082 pos.vx2 = 0; //x cord 00083 pos.vy2 = 0; //y cprd 00084 pos.vd2 = 0; //dircection 00085 pos.vc2 = 0; //counter 00086 pos.vl2 = 0; //length 00087 pos.vh2 = 0; //heighht 00088 00089 return pos; 00090 } 00091 00092 00093 //initializes data for spikes 00094 Pos Levels::init_spike(Pos pos) 00095 { 00096 pos.sx = 0; 00097 pos.sy = 0; 00098 pos.sl = 0; 00099 00100 return pos; 00101 } 00102 00103 00104 //initializes counter 1 00105 void Levels::init_counter1() 00106 { 00107 _counter1 = 0; 00108 00109 } 00110 00111 00112 //initializes counter 2 00113 void Levels::init_counter2() 00114 { 00115 _counter2 = 0; 00116 00117 } 00118 00119 00120 //Creates a horizontal moving platform, and returns cordinates to pos struct 00121 Pos Levels::moving_platform_hoz(N5110 &lcd, Pos pos, int x, int y, int w, int h, int dx, int s) //x cord, y cord, width, hight, move too point, initial starting point. 00122 { 00123 00124 if (pos.c == 0) { //sets counter to start point on first run, 00125 pos.c = s; //pos.c never returns to 0, so it only happens when the level loads 00126 } 00127 00128 if (pos.d == 0) { //if direction is 0, move right 00129 pos.c++; 00130 } else { //if direction is 1, move left 00131 pos.c--; 00132 } 00133 00134 if (pos.c == dx || pos.c == 1 ) { //when moving platform meets dx (move to point) direction pivots, 00135 pos.d = !pos.d; //same again, when moving platform reaches 1 00136 } 00137 00138 pos.x = x + pos.c; //pass x cord + counter to pos struct 00139 pos.y = y; //pass y cord to pos struct 00140 pos.l = w; //pass width to pos struct 00141 00142 00143 lcd.drawLine(pos.x, pos.y, pos.x + w, pos.y, 1); //draw the moving platform using specified width and height parameters 00144 lcd.drawLine(pos.x, pos.y+h, pos.x + w, pos.y+h, 1); 00145 lcd.drawLine(pos.x, pos.y, pos.x, pos.y+h, 1); 00146 lcd.drawLine(pos.x+w, pos.y, pos.x +w, pos.y+h, 1); 00147 00148 return pos; //return pos (the position and state of the moving platform) 00149 } 00150 00151 00152 //Creates a vertical moving platform, and returns cordinates to pos struct 00153 Pos Levels::moving_platform_ver(N5110 &lcd, Pos pos, int x, int y, int h, int w, int dx, int s) //x cord, y cord, width, hight, move too point, initial starting point. 00154 { 00155 if (pos.c == 0) { //sets counter to start point on first run, 00156 pos.c = s; //pos.c never returns to 0, so it only happens when the level loads 00157 } 00158 00159 if (pos.d == 0) { //if direction is 0, move down 00160 pos.c++; 00161 } else { //if direction is 1, move up 00162 pos.c--; 00163 } 00164 00165 if (pos.c == dx || pos.c == 1 ) { //when moving platform meets dx (move to point) direction pivots, 00166 pos.d = !pos.d; //same again, when moving platform reaches 1 00167 } 00168 00169 pos.x = x; //pass x cord to pos struct 00170 pos.y = y + pos.c; //pass y cord + counter to pos struct 00171 pos.l = w; //pass width to pos struct 00172 pos.h = h; //pass height to pos struct 00173 00174 lcd.drawLine(pos.x, pos.y, pos.x, pos.y+h, 1); //draw the moving platform using specified width and height parameters 00175 lcd.drawLine(pos.x, pos.y, pos.x+w, pos.y, 1); 00176 lcd.drawLine(pos.x+w, pos.y, pos.x+w, pos.y+h, 1); 00177 lcd.drawLine(pos.x, pos.y+h, pos.x+w, pos.y+h, 1); 00178 00179 return pos; //return pos (the position and state of the moving platform) 00180 } 00181 00182 00183 //print a singular spike at x, y 00184 void Levels::spike_up(N5110 &lcd, int x, int y) 00185 { 00186 00187 lcd.setPixel(x, y, true); 00188 lcd.setPixel(x+1, y-1, true); 00189 lcd.setPixel(x+1, y-2, true); 00190 lcd.setPixel(x+2, y, true); 00191 } 00192 00193 00194 //print a row of spikes of 'n' length, at x y 00195 Pos Levels::spike_row_up(N5110 &lcd, Pos pos, int x, int y, int n) 00196 { 00197 00198 for (int i = 0; i < n; i++) { //for n times, 00199 spike_up(lcd, x+i*2, y); //draw a spike 00200 } 00201 00202 pos.sx = x; //pass cordinatres to pos struct 00203 pos.sy = y; //pass cordinates to pos struct 00204 pos.sl = n*2 +1; //pass cordinates to pos struct 00205 00206 return pos; 00207 } 00208 00209 00210 //depending on input, print following levels 00211 Pos Levels::what_level(N5110 &lcd, int level) 00212 { 00213 switch (level) { 00214 case 0: 00215 _pos = level_zero(lcd); 00216 break; 00217 case 1: 00218 _pos = level_one(lcd); 00219 break; 00220 case 2: 00221 _pos = level_two(lcd); 00222 break; 00223 case 3: 00224 _pos = level_three(lcd); 00225 break; 00226 case 4: 00227 _pos = level_four(lcd); 00228 break; 00229 case 5: 00230 _pos = level_five(lcd); 00231 break; 00232 case 6: 00233 _pos = level_six(lcd); 00234 break; 00235 case 7: 00236 _pos = level_seven(lcd); 00237 break; 00238 case 8: 00239 _pos = level_eight(lcd); 00240 break; 00241 case 9: 00242 _pos = level_nine(lcd); 00243 break; 00244 case 10: 00245 _pos = level_ten(lcd); 00246 break; 00247 default: 00248 exit(1); 00249 break; 00250 } 00251 return _pos; 00252 } 00253 00254 00255 //transfer hoz1 into spare variables of original pos struct. 00256 Pos Levels::pass_data_hoz1(Pos pos, Pos hoz) 00257 { 00258 pos.x = hoz.x; 00259 pos.y = hoz.y; 00260 pos.d = hoz.d; 00261 pos.c = hoz.c; 00262 pos.l = hoz.l; 00263 pos.h = hoz.h; 00264 00265 return pos; 00266 } 00267 00268 00269 //transfer hoz2 into spare variables of original pos struct. 00270 Pos Levels::pass_data_hoz2(Pos pos, Pos hoz2) 00271 { 00272 pos.x2 = hoz2.x; 00273 pos.y2 = hoz2.y; 00274 pos.d2 = hoz2.d; 00275 pos.c2 = hoz2.c; 00276 pos.l2 = hoz2.l; 00277 pos.h2 = hoz2.h; 00278 00279 return pos; 00280 } 00281 00282 00283 //transfer ver into spare variables of original pos struct. 00284 Pos Levels::pass_data_ver1(Pos pos, Pos ver) 00285 { 00286 pos.vx = ver.x; 00287 pos.vy = ver.y; 00288 pos.vd = ver.d; 00289 pos.vc = ver.c; 00290 pos.vl = ver.l; 00291 pos.vh = ver.h; 00292 return pos; 00293 } 00294 00295 00296 //transfer ver2 into spare variables of original pos struct. 00297 Pos Levels::pass_data_ver2(Pos pos, Pos ver2) 00298 { 00299 pos.vx2 = ver2.x; 00300 pos.vy2 = ver2.y; 00301 pos.vd2 = ver2.d; 00302 pos.vc2 = ver2.c; 00303 pos.vl2 = ver2.l; 00304 pos.vh2 = ver2.h; 00305 00306 return pos; 00307 } 00308 00309 00310 00311 //increment counter1 00312 void Levels::speech_counter1() 00313 { 00314 _counter1++; 00315 } 00316 00317 00318 //inrement counter2 00319 void Levels::speech_counter2() 00320 { 00321 _counter2++; 00322 } 00323 00324 00325 //print string 'why hello there' word by word 00326 void Levels::speech_one(N5110 &lcd) 00327 { 00328 00329 if (_counter1 > 5 && _counter1 < 15) { 00330 lcd.printString(" Why,",0,0); 00331 } 00332 00333 if (_counter1 > 8 && _counter1 < 11) { 00334 lcd.printString(" Hello",0,1); 00335 } 00336 00337 if (_counter1 > 10 && _counter1 < 16) { 00338 lcd.printString(" Hello there...",0,1); 00339 } 00340 00341 if (_counter1 > 15 && _counter1 < 17) { 00342 lcd.printString(" there...",0,1); 00343 } 00344 } 00345 00346 00347 //print string 'you must be ' word by word 00348 void Levels::speech_two(N5110 &lcd) 00349 { 00350 if (_counter1 >= 20 && _counter1 < 22) { 00351 lcd.printString(" You ",0,0); 00352 } 00353 00354 if (_counter1 >= 22 && _counter1 < 23) { 00355 lcd.printString(" You must ",0,0); 00356 } 00357 00358 if (_counter1 >= 23 && _counter1 < 29) { 00359 lcd.printString(" You must be",0,0); 00360 } 00361 00362 if (_counter1 >= 29 && _counter1 < 30) { 00363 lcd.printString(" must be",0,0); 00364 } 00365 00366 if (_counter1 >= 30 && _counter1 < 31) { 00367 lcd.printString(" be",0,0); 00368 } 00369 00370 } 00371 00372 00373 //print string 'the new guy' word by word 00374 void Levels::speech_three(N5110 &lcd) 00375 { 00376 if (_counter1 >= 24 && _counter1 < 25) { 00377 lcd.printString(" The ",0,1); 00378 } 00379 if (_counter1 >= 25 && _counter1 < 26) { 00380 lcd.printString(" The new",0,1); 00381 } 00382 if (_counter1 >= 26 && _counter1 < 32) { 00383 lcd.printString(" The new guy.,",0,1); 00384 } 00385 if (_counter1 >= 32 && _counter1 < 33) { 00386 lcd.printString(" new guy.,",0,1); 00387 } 00388 if (_counter1 >= 33 && _counter1 < 34) { 00389 lcd.printString(" guy.,",0,1); 00390 } 00391 } 00392 00393 00394 //print string 'use joy stick to move-go right' word by word 00395 void Levels::speech_four(N5110 &lcd) 00396 { 00397 if (_counter1 >= 40) { 00398 lcd.printString(" Use jystck to",0,0); 00399 lcd.printString("move-GO RIGHT!",0,1); 00400 } 00401 } 00402 00403 00404 //print string 'shame what' word by word 00405 void Levels::speech_five(N5110 &lcd) 00406 { 00407 00408 if (_counter2 >= 5 && _counter2 < 6) { 00409 lcd.printString(" Shame ",0,0); 00410 } 00411 if (_counter2 >= 6 && _counter2 < 10) { 00412 lcd.printString(" Shame what",0,0); 00413 } 00414 if (_counter2 >= 10 && _counter2 < 11) { 00415 lcd.printString(" what",0,0); 00416 } 00417 } 00418 00419 00420 //print string 'happened to' word by word 00421 void Levels::speech_six(N5110 &lcd) 00422 { 00423 00424 if (_counter2 >= 7 && _counter2 < 8) { 00425 lcd.printString(" happened ",0,1); 00426 } 00427 if (_counter2 >= 8 && _counter2 < 12) { 00428 lcd.printString(" happened to ",0,1); 00429 } 00430 if (_counter2 >= 12 && _counter2 < 13) { 00431 lcd.printString(" to ",0,1); 00432 } 00433 } 00434 00435 00436 //print string 'the last lad...' word by word 00437 void Levels::speech_seven(N5110 &lcd) 00438 { 00439 00440 if (_counter2 >= 13 && _counter2 < 14) { 00441 lcd.printString(" the ",0,0); 00442 } 00443 if (_counter2 >= 14 && _counter2 < 20) { 00444 lcd.printString(" the last",0,0); 00445 } 00446 if (_counter2 >= 20 && _counter2 < 21) { 00447 lcd.printString(" last",0,0); 00448 } 00449 00450 if (_counter2 >= 16 && _counter2 < 23) { 00451 lcd.printString(" lad...",0,1); 00452 } 00453 } 00454 00455 00456 //print string 'press button a to jump' word by word 00457 void Levels::speech_eight(N5110 &lcd) 00458 { 00459 if (_counter2 >= 26) { 00460 lcd.printString(" Press button",0,0); 00461 lcd.printString(" A to jump",0,1); 00462 } 00463 } 00464 00465 00466 //print string 'I was just' word by word 00467 void Levels::speech_nine(N5110 &lcd) 00468 { 00469 00470 if (_counter1 >= 5 && _counter1 < 6) { 00471 lcd.printString(" I ",0,0); 00472 } 00473 if (_counter1 >= 6 && _counter1 < 7) { 00474 lcd.printString(" I was",0,0); 00475 } 00476 if (_counter1 >= 7 && _counter1 < 10) { 00477 lcd.printString(" I was just",0,0); 00478 } 00479 if (_counter1 >= 10 && _counter1 < 11) { 00480 lcd.printString(" was just",0,0); 00481 } 00482 if (_counter1 >= 11 && _counter1 < 12) { 00483 lcd.printString(" just",0,0); 00484 } 00485 } 00486 00487 00488 //print string 'starting to' word by word 00489 void Levels::speech_ten(N5110 &lcd) 00490 { 00491 00492 if (_counter1 >= 8 && _counter1 < 13) { 00493 lcd.printString("starting ",0,1); 00494 } 00495 if (_counter1 >= 9 && _counter1 < 14) { 00496 lcd.printString("starting to ",0,1); 00497 } 00498 if (_counter1 >= 14 && _counter1 < 15) { 00499 lcd.printString(" to",0,1); 00500 } 00501 } 00502 00503 00504 //print string 'like him' word by word 00505 void Levels::speech_elleven(N5110 &lcd) 00506 { 00507 00508 if (_counter1 >= 14 && _counter1 < 15) { 00509 lcd.printString(" like ",0,0); 00510 } 00511 if (_counter1 >= 15 && _counter1 < 25) { 00512 lcd.printString(" like him",0,0); 00513 } 00514 if (_counter1 >= 25 && _counter1 < 26) { 00515 lcd.printString(" him",0,0); 00516 } 00517 } 00518 00519 00520 //print string 'as well!' word by word 00521 void Levels::speech_twelve(N5110 &lcd) 00522 { 00523 00524 if (_counter1 >= 16 && _counter1 < 17) { 00525 lcd.printString(" as ",0,1); 00526 } 00527 if (_counter1 >= 17 && _counter1 < 27) { 00528 lcd.printString(" as well! ",0,1); 00529 } 00530 if (_counter1 >= 27 && _counter1 < 28) { 00531 lcd.printString(" well! ",0,1); 00532 } 00533 } 00534 00535 00536 //print string 'Here's an idea..' word by word 00537 void Levels::speech_thirteen(N5110 &lcd) 00538 { 00539 if (_counter2 >= 5 && _counter2 < 12) { 00540 lcd.printString("Here's", 55, 3); 00541 } 00542 if (_counter2 >= 6 && _counter2 < 13) { 00543 lcd.printString("an", 42, 4); 00544 } 00545 if (_counter2 >= 7 && _counter2 < 14) { 00546 lcd.printString("idea..", 45, 5); 00547 } 00548 } 00549 00550 00551 //print string 'try a wall jump' word by word 00552 void Levels::speech_forteen(N5110 &lcd) 00553 { 00554 if (_counter2 >= 13 && _counter2 < 22) { 00555 lcd.printString("try", 60, 3); 00556 } 00557 if (_counter2 >= 14 && _counter2 < 23) { 00558 lcd.printString("a", 45, 4); 00559 } 00560 if (_counter2 >= 14 && _counter2 < 23) { 00561 lcd.printString("a wall", 45, 4); 00562 } 00563 if (_counter2 >= 14 && _counter2 < 23) { 00564 lcd.printString("a wall", 45, 4); 00565 } 00566 if (_counter2 >= 16 && _counter2 < 25) { 00567 lcd.printString("jump!", 50, 5); 00568 } 00569 } 00570 00571 00572 //run level one 00573 Pos Levels::level_one(N5110 &lcd) 00574 { 00575 00576 lcd.drawLine(0,40,84,40,1); //draw lines for level 00577 00578 speech_level_one(lcd); //display speech for level 00579 00580 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00581 00582 return _pos; //return postions of moving platforms if any. 00583 00584 } 00585 00586 00587 //run level one speech 00588 void Levels::speech_level_one(N5110 &lcd) 00589 { 00590 speech_counter1(); //counter increments 00591 speech_one(lcd); //speech appears according to counter 00592 speech_two(lcd); 00593 speech_three(lcd); 00594 speech_four(lcd); 00595 } 00596 00597 Pos Levels::init_level_one(Pos pos) 00598 { 00599 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00600 _pos = init_hoz2(_pos); 00601 _pos = init_ver1(_pos); 00602 _pos = init_ver2(_pos); 00603 _pos = init_spike(_pos); 00604 init_counter2(); 00605 00606 return _pos; 00607 } 00608 00609 //run level two 00610 Pos Levels::level_two(N5110 &lcd) 00611 { 00612 00613 00614 lcd.drawLine(0,40,35,40,1); //draw lines for level 00615 lcd.drawLine(35,40,35,48,1); 00616 lcd.drawLine(50,40,84,40,1); 00617 lcd.drawLine(50,40,50,48,1); 00618 00619 speech_level_two(lcd); //display speech for level 00620 00621 _pos = init_level_two(_pos); 00622 00623 return _pos; //return postions of moving platforms if any. 00624 } 00625 00626 00627 //intialises all platform variables not being used in level 2 00628 Pos Levels::init_level_two(Pos pos) 00629 { 00630 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00631 _pos = init_hoz2(_pos); 00632 _pos = init_ver1(_pos); 00633 _pos = init_ver2(_pos); 00634 _pos = init_spike(_pos); 00635 init_counter1(); 00636 00637 return _pos; 00638 } 00639 00640 00641 //run level two speech 00642 void Levels::speech_level_two(N5110 &lcd) 00643 { 00644 speech_counter2(); //counter increments 00645 speech_five(lcd); //speech appears according to counter 00646 speech_six(lcd); 00647 speech_seven(lcd); 00648 speech_eight(lcd); 00649 } 00650 00651 00652 //run level three 00653 Pos Levels::level_three(N5110 &lcd) 00654 { 00655 lcd.drawLine(0,40,15,40,1); //draw lines for level 00656 lcd.drawLine(15,40,15,48,1); 00657 lcd.drawLine(70,40,84,40,1); 00658 lcd.drawLine(70,40,70,48,1); 00659 00660 lcd.drawLine(74,14,74,0,1); 00661 lcd.drawLine(74,14,84,14,1); 00662 00663 _hoz1 = moving_platform_hoz(lcd, _hoz1, 25, 40, 10, 3, 25, 1); //set parameters for horizontal moving platform 00664 _pos = pass_data_hoz1(_pos, _hoz1); 00665 00666 speech_level_three(lcd); //display speech for level 00667 00668 _pos = init_level_three(_pos); 00669 00670 return _pos; 00671 } 00672 00673 00674 //intialises all platform variables not being used in level 3 00675 Pos Levels::init_level_three(Pos pos) 00676 { 00677 //intialise all variables not being used in level 00678 _pos = init_hoz2(_pos); 00679 _pos = init_ver1(_pos); 00680 _pos = init_ver2(_pos); 00681 _pos = init_spike(_pos); 00682 init_counter2(); 00683 00684 return _pos; 00685 } 00686 00687 00688 //run level three speech 00689 void Levels::speech_level_three(N5110 &lcd) 00690 { 00691 speech_counter1(); //counter increments 00692 speech_nine(lcd); //speech appears according to counter 00693 speech_ten(lcd); 00694 speech_elleven(lcd); 00695 speech_twelve(lcd); 00696 } 00697 00698 00699 //run level four 00700 Pos Levels::level_four(N5110 &lcd) 00701 { 00702 00703 lcd.drawLine(0,40,84,40,1); //draw lines for level 00704 lcd.drawLine(0,14,10,14,1); 00705 lcd.drawLine(10,0,10,14,1); 00706 00707 lcd.drawLine(74,14,74,0,1); 00708 lcd.drawLine(74,14,84,14,1); 00709 00710 _ver1 = moving_platform_ver(lcd, _ver1, 11, 0, 18, 30, 21, 10); //set parameters for vertical moving platform 00711 _pos = pass_data_ver1(_pos, _ver1); 00712 _ver2 = moving_platform_ver(lcd, _ver2, 42, 0, 18, 31, 21, 1); //set parameters for vertical 2 moving platform 00713 _pos = pass_data_ver2(_pos, _ver2); 00714 00715 _pos = init_level_four(_pos); 00716 00717 return _pos; 00718 00719 00720 } 00721 00722 00723 //intialises all platform variables not being used in level 4 00724 Pos Levels::init_level_four(Pos pos) 00725 { 00726 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00727 _pos = init_hoz2(_pos); 00728 _pos = init_spike(_pos); 00729 init_counter2(); 00730 init_counter1(); 00731 00732 return _pos; 00733 } 00734 00735 00736 //run level five 00737 Pos Levels::level_five(N5110 &lcd) 00738 { 00739 00740 lcd.drawLine(0,40,40,40,1); //draw lines for level 00741 lcd.drawLine(40,40,40,20,1); 00742 lcd.drawLine(40,20,84,20,1); 00743 00744 lcd.drawLine(0,14,10,14,1); 00745 lcd.drawLine(10,14,10,25,1); 00746 lcd.drawLine(10,25,20,25,1); 00747 lcd.drawLine(20,0,20,25,1); 00748 00749 speech_counter2(); //run speech for level 00750 speech_thirteen(lcd); 00751 speech_forteen(lcd); 00752 00753 _pos = spike_row_up(lcd, _pos, 55, 19, 5); //set parameters for spikes 00754 00755 _pos = init_level_five(_pos); 00756 00757 return _pos; 00758 00759 } 00760 00761 00762 00763 //intialises all platform variables not being used in level 4 00764 Pos Levels::init_level_five(Pos pos) 00765 { 00766 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00767 _pos = init_hoz2(_pos); 00768 _pos = init_ver1(_pos); 00769 _pos = init_ver2(_pos); 00770 init_counter1(); 00771 00772 return _pos; 00773 } 00774 00775 00776 //run level six 00777 Pos Levels::level_six(N5110 &lcd) 00778 { 00779 00780 lcd.drawLine(0,20,10,20,1); //draw lines for level 00781 lcd.drawLine(10,20,10,48,1); 00782 lcd.drawLine(74,48,74,20,1); 00783 lcd.drawLine(74,20,84,20,1); 00784 00785 _ver1 = moving_platform_ver(lcd, _ver1, 23, 10, 3, 5, 20, 1); //set parameters for vertical moving platform 00786 _pos = pass_data_ver1(_pos, _ver1); 00787 00788 _ver2 = moving_platform_ver(lcd, _ver2, 56, 10, 3, 5, 20, 19); //set parameters for vertical 2 moving platform 00789 _pos = pass_data_ver2(_pos, _ver2); 00790 00791 _pos = init_level_six(_pos); 00792 00793 return _pos; 00794 } 00795 00796 00797 00798 00799 //intialises all platform variables not being used in level 6 00800 Pos Levels::init_level_six(Pos pos) 00801 { 00802 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00803 _pos = init_hoz2(_pos); 00804 init_counter2(); 00805 init_counter1(); 00806 _pos = init_spike(_pos); 00807 00808 return _pos; 00809 } 00810 00811 00812 //run level seven 00813 Pos Levels::level_seven(N5110 &lcd) 00814 { 00815 lcd.drawLine(0,20,10,20,1); //draw lines for level 00816 lcd.drawLine(10,20,10,48,1); 00817 00818 lcd.drawLine(50,39,56,39,1); 00819 lcd.drawLine(50,39,50,37,1); 00820 lcd.drawLine(56,37,56,39,1); 00821 00822 lcd.drawLine(70,40,84,40,1); 00823 lcd.drawLine(70,40,70,48,1); 00824 00825 _hoz1 = moving_platform_hoz(lcd, _hoz1, 20, 40, 20, 3, 25, 1); //set parameters for horizontal moving platform 00826 _pos = pass_data_hoz1(_pos, _hoz1); 00827 00828 _pos = spike_row_up(lcd, _pos, 50, 37, 3); //set parameters for spikes 00829 00830 _pos = init_level_seven(_pos); //intialise all variables not being used in level 00831 00832 00833 return _pos; 00834 } 00835 00836 00837 //intialises all platform variables not being used in level 7 00838 Pos Levels::init_level_seven(Pos pos) 00839 { 00840 _pos = init_hoz2(_pos); 00841 _pos = init_ver1(_pos); 00842 _pos = init_ver2(_pos); 00843 init_counter2(); 00844 00845 return _pos; 00846 } 00847 00848 00849 //run level eight 00850 Pos Levels::level_eight(N5110 &lcd) 00851 { 00852 00853 lcd.drawLine(0,40,10,40,1); //draw lines for level 00854 lcd.drawLine(10,40,10,48,1); 00855 00856 lcd.drawLine(22,48,22,32,1); 00857 lcd.drawLine(62,48,62,32,1); 00858 lcd.drawLine(22,32,62,32,1); 00859 00860 lcd.drawLine(74,10,84,10,1); 00861 lcd.drawLine(74,10,74,48,1); 00862 00863 00864 _ver1 = moving_platform_ver(lcd, _ver1, 11, 10, 40, 10, 25, 1); //set parameters for vertical moving platform 00865 _pos = pass_data_ver1(_pos, _ver1); 00866 _ver2 = moving_platform_ver(lcd, _ver2, 63, 15, 40, 10, 25, 24); //set parameters for vertical moving platform 2 00867 _pos = pass_data_ver2(_pos, _ver2); 00868 00869 _pos = spike_row_up(lcd, _pos, 24, 31, 18); //set parameters for spikes 00870 00871 _pos = init_level_eight(_pos); 00872 00873 return _pos; 00874 } 00875 00876 00877 //intialises all platform variables not being used in level 8 00878 Pos Levels::init_level_eight(Pos pos) 00879 { 00880 _pos = init_hoz1(_pos); //intialise all variables not being used in level 00881 _pos = init_hoz2(_pos); 00882 init_counter2(); 00883 00884 return _pos; 00885 } 00886 00887 00888 //run level nine 00889 Pos Levels::level_nine(N5110 &lcd) 00890 { 00891 00892 lcd.drawLine(0,10,25,10,1); 00893 lcd.drawLine(25,12,25,10,1); 00894 lcd.drawLine(25,12,5,12,1); 00895 lcd.drawLine(5,12,5,48,1); 00896 00897 lcd.drawLine(45,0,45,25,1); 00898 lcd.drawLine(45,25,20,25,1); 00899 lcd.drawLine(20,25,20,28,1); 00900 lcd.drawLine(20,28,55,28,1); 00901 lcd.drawLine(55,28,65,0,1); 00902 00903 00904 lcd.drawLine(30,46,70,46,1); 00905 lcd.drawLine(70,46,70,40,1); 00906 lcd.drawLine(70,40,84,40,1); 00907 lcd.drawLine(30,46,30,48,1); 00908 00909 _pos = init(_pos); 00910 00911 return _pos; 00912 } 00913 00914 00915 00916 //run level ten 00917 Pos Levels::level_ten(N5110 &lcd) 00918 { 00919 00920 _pos = init(_pos); 00921 00922 lcd.drawLine(0,40,70,40,1); 00923 lcd.drawLine(70,40,70,0,1); 00924 00925 lcd.printString(" ..the end,", 0, 0); 00926 lcd.printString("now what??", 0, 1); 00927 return _pos; 00928 } 00929 00930 00931 //run level zero 00932 Pos Levels::level_zero(N5110 &lcd) 00933 { 00934 lcd.printString(" I said the ", 0, 0); 00935 lcd.printString(" other Way.. ", 0, 1); 00936 lcd.drawLine(84,40,10,40,1); 00937 lcd.drawLine(10,40,10,0,1); 00938 00939 00940 return _pos; 00941 }
Generated on Fri Jul 15 2022 00:42:15 by
