void s3dge::loop_sound_callback(ga_Handle* handle, void* context) { Sound* sound = (Sound*)context; sound->Loop(); ga_handle_destroy(handle); }
void loop_on_finish(ga_Handle* in_handle, void* in_context) { Sound* sound = (Sound*) in_handle->sound; sound->Loop(); ga_handle_destroy(in_handle); }
int main(int argc, char *argv[]){ glutInit(&argc, argv); GameDebugger* debugger = GameDebugger::GetInstance(); assert(debugger->OpenDebugFile()); debugger->WriteDebugMessageToConsole("Hello, World", 31); debugger->WriteToDebugFile("Wrote to file", 32); TaskQueue *taskManager = new TaskQueue(NUM_THREADS); ConsoleCreateRoom(); GameRoom gr; if (argc > 1){ string path = pathCat(GAME_DATA_ROOMS_FOLDER, argv[1]); GameRoom::LoadRoom(path.c_str(), gr); } //For testing purposes. To make sure it reads debug.room char debugName[1000]; strcpy(debugName, GAME_DATA_ROOMS_FOLDER); strcat(debugName, "debug.room"); GameRoom debug; assert(GameRoom::LoadRoom(debugName, debug)); vector<GameObject*> obs = debug.GetGameObjects(); //map<string, GameWorldObject>::iterator wobs = debug.GetRoomWorldObjectsIterator(); for(unsigned int w = 0; w<obs.size(); w++){ //load starting meshes GameObject *gwo = obs[w]; cout<<gwo->GetName()<<endl; MyMesh *tmp = new MyMesh(); if (gwo->GetMeshFile()){ string fname = pathCat(".", gwo->GetMeshFile()); if (! MyMeshIO::LoadMesh(*tmp, fname)){ cerr<<"couldn't load (" << gwo->GetMeshFile() << ") for " <<gwo -> GetName() <<endl; gwo->SetMesh(NULL); }else{ gwo->SetMesh(tmp); NavShot::room = tmp; } } } ComputeBoundingBoxesAndPhysicsConstants(obs); //cin.ignore(1); /////////////////////////////////////////////////// //TODO: load from file GameState *gs = GameState::GetInstance(); Vector3f pos(0.0f, 0, -10.0f); Vector3f up(0, 1.0f, 0); Vector3f dir(0.0f, 0, 1.0f); float radius =0, n = 0.1, f = 600, fovy = 80, aspect = ((float)16.0/9.0); Camera cam(pos, dir, up, radius, n, f, fovy, aspect); gs->SetRoom(&debug); gs->SetCamera(&cam); Vector3f enemyPos(0.0f, 3.0f, 10.0f); gs->AddActor(new MetaballEnemy(enemyPos, 2, 2.0f)); Render::gameState = gs; Render::GlutInitialize(); SCollision::gameState = gs; RegisterControls(); Controller::Initialize(taskManager, gs); ///////////////////////////////////////////////// // TO DO: // Pass GameRoom debug to Render module. Render the // room. ///////////////////////////////////////////////// glutTimerFunc(0, Controller::GlutSync, 0); //glutMotionFunc(mouseMoveCB); //glutMouseFunc(mouseFunc); Sound::InitializeSounds(); Music *music = new Music("sounds/run2.ogg", 0.3f); music->Loop(); Sound *backgroundNoise = new Sound("sounds/metallic_roar.wav", 0.2f); backgroundNoise->Loop(); glutMainLoop(); //this should only be called once, and AT THE END of the initialization routine. Sound::UninitializeSounds(); assert(debugger->CloseDebugFile()); return 0; }