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 FATFileSystem
Game_Manager/Game_Manager.cpp@14:165fff6d1854, 2019-05-06 (annotated)
- Committer:
- rottenegg
- Date:
- Mon May 06 20:53:37 2019 +0000
- Revision:
- 14:165fff6d1854
- Child:
- 15:3d29fb195958
CaMove: Added Additional Chaser options eg. death zones/; Game_Manager: Added Manages all Scenes and Story events with RNG management, Booting Diagnostics and Game File Verification, AllPaths was added.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rottenegg | 14:165fff6d1854 | 1 | #include "Game_Manager.h" |
rottenegg | 14:165fff6d1854 | 2 | #include "AllPaths.h" |
rottenegg | 14:165fff6d1854 | 3 | |
rottenegg | 14:165fff6d1854 | 4 | Timer Time; |
rottenegg | 14:165fff6d1854 | 5 | |
rottenegg | 14:165fff6d1854 | 6 | Game_Manager::Game_Manager(PinName sd0, |
rottenegg | 14:165fff6d1854 | 7 | PinName sd1, |
rottenegg | 14:165fff6d1854 | 8 | PinName sd2, |
rottenegg | 14:165fff6d1854 | 9 | PinName sd3, |
rottenegg | 14:165fff6d1854 | 10 | PinName lcd0, |
rottenegg | 14:165fff6d1854 | 11 | PinName lcd1, |
rottenegg | 14:165fff6d1854 | 12 | PinName lcd2, |
rottenegg | 14:165fff6d1854 | 13 | PinName lcd3, |
rottenegg | 14:165fff6d1854 | 14 | PinName lcd4, |
rottenegg | 14:165fff6d1854 | 15 | PinName lcd5, |
rottenegg | 14:165fff6d1854 | 16 | PinName cm0, |
rottenegg | 14:165fff6d1854 | 17 | PinName cm1, |
rottenegg | 14:165fff6d1854 | 18 | PinName cm2, |
rottenegg | 14:165fff6d1854 | 19 | PinName wd, |
rottenegg | 14:165fff6d1854 | 20 | PinName sc ) |
rottenegg | 14:165fff6d1854 | 21 | : |
rottenegg | 14:165fff6d1854 | 22 | sd(new SDFileSystem(sd0, sd1, sd2, sd3, "sd")), |
rottenegg | 14:165fff6d1854 | 23 | lcd(new N5110(lcd0,lcd1,lcd2,lcd3,lcd4,lcd5)), |
rottenegg | 14:165fff6d1854 | 24 | CM(new CaMove(cm0,cm1,cm2)), |
rottenegg | 14:165fff6d1854 | 25 | wav(new WDplayer(wd)), |
rottenegg | 14:165fff6d1854 | 26 | SNC(new SceneCreator(sc)) |
rottenegg | 14:165fff6d1854 | 27 | |
rottenegg | 14:165fff6d1854 | 28 | {}; |
rottenegg | 14:165fff6d1854 | 29 | |
rottenegg | 14:165fff6d1854 | 30 | |
rottenegg | 14:165fff6d1854 | 31 | bool Game_Manager::boot_error() { |
rottenegg | 14:165fff6d1854 | 32 | //Check SD card Status |
rottenegg | 14:165fff6d1854 | 33 | lcd->init(); |
rottenegg | 14:165fff6d1854 | 34 | lcd->clear(); |
rottenegg | 14:165fff6d1854 | 35 | lcd->printString("BOOTING...",0,0); |
rottenegg | 14:165fff6d1854 | 36 | lcd->refresh(); |
rottenegg | 14:165fff6d1854 | 37 | sd->disk_initialize(); |
rottenegg | 14:165fff6d1854 | 38 | int check = sd->disk_status(); |
rottenegg | 14:165fff6d1854 | 39 | if (check == 1) { |
rottenegg | 14:165fff6d1854 | 40 | lcd->printString("SD Card Error",0,0); |
rottenegg | 14:165fff6d1854 | 41 | lcd->printString("Details in ",0,1); |
rottenegg | 14:165fff6d1854 | 42 | lcd->printString("Terminal try",0,2); |
rottenegg | 14:165fff6d1854 | 43 | lcd->printString("Re-inserting",0,3); |
rottenegg | 14:165fff6d1854 | 44 | lcd->printString("SD Card",0,4); |
rottenegg | 14:165fff6d1854 | 45 | lcd->refresh(); |
rottenegg | 14:165fff6d1854 | 46 | return true; |
rottenegg | 14:165fff6d1854 | 47 | } else { |
rottenegg | 14:165fff6d1854 | 48 | std::cerr << "Error Report" << std::endl; |
rottenegg | 14:165fff6d1854 | 49 | if (this->check()) { |
rottenegg | 14:165fff6d1854 | 50 | lcd->clear(); |
rottenegg | 14:165fff6d1854 | 51 | lcd->printString("Game Files",0,0); |
rottenegg | 14:165fff6d1854 | 52 | lcd->printString("Missing",0,1); |
rottenegg | 14:165fff6d1854 | 53 | lcd->printString("Details in",0,2); |
rottenegg | 14:165fff6d1854 | 54 | lcd->printString("Terminal",0,3); |
rottenegg | 14:165fff6d1854 | 55 | lcd->refresh(); |
rottenegg | 14:165fff6d1854 | 56 | return true; |
rottenegg | 14:165fff6d1854 | 57 | } else { |
rottenegg | 14:165fff6d1854 | 58 | std::cerr << "Boot Successful No Errors" << std::endl; |
rottenegg | 14:165fff6d1854 | 59 | } |
rottenegg | 14:165fff6d1854 | 60 | } |
rottenegg | 14:165fff6d1854 | 61 | return false; |
rottenegg | 14:165fff6d1854 | 62 | } |
rottenegg | 14:165fff6d1854 | 63 | |
rottenegg | 14:165fff6d1854 | 64 | void Game_Manager::main() { |
rottenegg | 14:165fff6d1854 | 65 | const char *path; |
rottenegg | 14:165fff6d1854 | 66 | path = "/sd/Game-Files/AudBin/play1.wav"; |
rottenegg | 14:165fff6d1854 | 67 | wav->intWD(path, true); |
rottenegg | 14:165fff6d1854 | 68 | Time.start(); |
rottenegg | 14:165fff6d1854 | 69 | SNC->Scenesp(*lcd,*CM,0,40,20,Fd,0,*wav); |
rottenegg | 14:165fff6d1854 | 70 | |
rottenegg | 14:165fff6d1854 | 71 | Time.stop(); |
rottenegg | 14:165fff6d1854 | 72 | int Random = (int)Time.read(); |
rottenegg | 14:165fff6d1854 | 73 | Random = Random % 3; |
rottenegg | 14:165fff6d1854 | 74 | |
rottenegg | 14:165fff6d1854 | 75 | if (Random == 0 || Random == 1) { |
rottenegg | 14:165fff6d1854 | 76 | wav->intWD(path, true); |
rottenegg | 14:165fff6d1854 | 77 | SNC->Scenesp(*lcd,*CM,1,35,29,Fd,0,*wav); |
rottenegg | 14:165fff6d1854 | 78 | wav->intWD(path, true); |
rottenegg | 14:165fff6d1854 | 79 | SNC->Scenesp(*lcd,*CM,2,61,17,Lt,0,*wav); |
rottenegg | 14:165fff6d1854 | 80 | } else { |
rottenegg | 14:165fff6d1854 | 81 | wav->intWD(path, true); |
rottenegg | 14:165fff6d1854 | 82 | SNC->Scenesp(*lcd,*CM,3,58,26,Bd,0,*wav); |
rottenegg | 14:165fff6d1854 | 83 | } |
rottenegg | 14:165fff6d1854 | 84 | } |
rottenegg | 14:165fff6d1854 | 85 | /* |
rottenegg | 14:165fff6d1854 | 86 | const char *path; |
rottenegg | 14:165fff6d1854 | 87 | path = "/sd/Game-Files/AudBin/play1.wav"; |
rottenegg | 14:165fff6d1854 | 88 | wav.intWD(path, true); |
rottenegg | 14:165fff6d1854 | 89 | Time.start(); |
rottenegg | 14:165fff6d1854 | 90 | SNC.Scenesp(lcd,CM,0,40,20,Fd,0,wav); |
rottenegg | 14:165fff6d1854 | 91 | Time.stop(); |
rottenegg | 14:165fff6d1854 | 92 | int Random = (int)Time.read(); |
rottenegg | 14:165fff6d1854 | 93 | Random = Random % 3; |
rottenegg | 14:165fff6d1854 | 94 | wav.intWD(path, true); |
rottenegg | 14:165fff6d1854 | 95 | SNC.Scenesp(lcd,CM,1,35,29,Fd,Random,wav); |
rottenegg | 14:165fff6d1854 | 96 | wav.intWD(path, true); |
rottenegg | 14:165fff6d1854 | 97 | SNC.Scenesp(lcd,CM,2,61,17,Lt,Random,wav); |
rottenegg | 14:165fff6d1854 | 98 | wav.intWD(path, true); |
rottenegg | 14:165fff6d1854 | 99 | SNC.Scenesp(lcd,CM,3,58,26,Bd,0,wav); |
rottenegg | 14:165fff6d1854 | 100 | */ |
rottenegg | 14:165fff6d1854 | 101 | |
rottenegg | 14:165fff6d1854 | 102 | bool Game_Manager::check() { |
rottenegg | 14:165fff6d1854 | 103 | FILE *bmp; |
rottenegg | 14:165fff6d1854 | 104 | bool error = false; |
rottenegg | 14:165fff6d1854 | 105 | for (int i = 0; i <= 34; i++) { |
rottenegg | 14:165fff6d1854 | 106 | bmp = fopen(All[i],"r"); |
rottenegg | 14:165fff6d1854 | 107 | if (bmp == NULL) { |
rottenegg | 14:165fff6d1854 | 108 | std::cerr << All[i] << " is not present" << std::endl; |
rottenegg | 14:165fff6d1854 | 109 | error = true; |
rottenegg | 14:165fff6d1854 | 110 | } else { |
rottenegg | 14:165fff6d1854 | 111 | fclose(bmp); |
rottenegg | 14:165fff6d1854 | 112 | } |
rottenegg | 14:165fff6d1854 | 113 | } |
rottenegg | 14:165fff6d1854 | 114 | return error; |
rottenegg | 14:165fff6d1854 | 115 | } |