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
- Committer:
- rottenegg
- Date:
- 2019-05-07
- Revision:
- 15:3d29fb195958
- Parent:
- 14:165fff6d1854
- Child:
- 17:7d4d8905b608
File content as of revision 15:3d29fb195958:
#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); } else { wav->intWD(path, true); SNC->Scenesp(*lcd,*CM,3,58,26,Bd,0,*wav); } if (Random == 2 && SNC->get_dead()) { //go death } else if ((Random == 2 && !SNC->get_dead()) || (Random != 2 && SNC->get_dead())) { SNC->set_dead(false); wav->intWD(path, true); SNC->Scenesp(*lcd,*CM,4,69,19,Rt,0,*wav); } else { wav->intWD(path, true); SNC->Scenesp(*lcd,*CM,2,61,17,Lt,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; }