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
Diff: Game_Manager/Game_Manager.cpp
- Revision:
- 14:165fff6d1854
- Child:
- 15:3d29fb195958
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Game_Manager/Game_Manager.cpp Mon May 06 20:53:37 2019 +0000 @@ -0,0 +1,115 @@ +#include "Game_Manager.h" +#include "AllPaths.h" + +Timer Time; + +Game_Manager::Game_Manager(PinName sd0, + PinName sd1, + PinName sd2, + PinName sd3, + PinName lcd0, + PinName lcd1, + PinName lcd2, + PinName lcd3, + PinName lcd4, + PinName lcd5, + PinName cm0, + PinName cm1, + PinName cm2, + PinName wd, + PinName sc ) + : + sd(new SDFileSystem(sd0, sd1, sd2, sd3, "sd")), + lcd(new N5110(lcd0,lcd1,lcd2,lcd3,lcd4,lcd5)), + CM(new CaMove(cm0,cm1,cm2)), + wav(new WDplayer(wd)), + SNC(new SceneCreator(sc)) + +{}; + + +bool Game_Manager::boot_error() { + //Check SD card Status + lcd->init(); + lcd->clear(); + lcd->printString("BOOTING...",0,0); + lcd->refresh(); + sd->disk_initialize(); + int check = sd->disk_status(); + if (check == 1) { + lcd->printString("SD Card Error",0,0); + lcd->printString("Details in ",0,1); + lcd->printString("Terminal try",0,2); + lcd->printString("Re-inserting",0,3); + lcd->printString("SD Card",0,4); + lcd->refresh(); + return true; + } else { + std::cerr << "Error Report" << std::endl; + if (this->check()) { + lcd->clear(); + lcd->printString("Game Files",0,0); + lcd->printString("Missing",0,1); + lcd->printString("Details in",0,2); + lcd->printString("Terminal",0,3); + lcd->refresh(); + return true; + } else { + std::cerr << "Boot Successful No Errors" << std::endl; + } + } + return false; +} + +void Game_Manager::main() { + const char *path; + path = "/sd/Game-Files/AudBin/play1.wav"; + wav->intWD(path, true); + Time.start(); + SNC->Scenesp(*lcd,*CM,0,40,20,Fd,0,*wav); + + Time.stop(); + int Random = (int)Time.read(); + Random = Random % 3; + + if (Random == 0 || Random == 1) { + wav->intWD(path, true); + SNC->Scenesp(*lcd,*CM,1,35,29,Fd,0,*wav); + wav->intWD(path, true); + SNC->Scenesp(*lcd,*CM,2,61,17,Lt,0,*wav); + } else { + wav->intWD(path, true); + SNC->Scenesp(*lcd,*CM,3,58,26,Bd,0,*wav); + } +} + /* + const char *path; + path = "/sd/Game-Files/AudBin/play1.wav"; + wav.intWD(path, true); + Time.start(); + SNC.Scenesp(lcd,CM,0,40,20,Fd,0,wav); + Time.stop(); + int Random = (int)Time.read(); + Random = Random % 3; + wav.intWD(path, true); + SNC.Scenesp(lcd,CM,1,35,29,Fd,Random,wav); + wav.intWD(path, true); + SNC.Scenesp(lcd,CM,2,61,17,Lt,Random,wav); + wav.intWD(path, true); + SNC.Scenesp(lcd,CM,3,58,26,Bd,0,wav); + */ + +bool Game_Manager::check() { + FILE *bmp; + bool error = false; + for (int i = 0; i <= 34; i++) { + bmp = fopen(All[i],"r"); + if (bmp == NULL) { + std::cerr << All[i] << " is not present" << std::endl; + error = true; + } else { + fclose(bmp); + } + } + return error; +}