void FieldViewerBase::IsVisible(bool bVisible) { _cmdManager.dispatchKey('b');//HACK to trigger a refresh _cmdManager.dispatchKey('B'); RenderObjectBase<FieldViewerBase>::IsVisible(bVisible); toggleRenderMode(); }
void Screen::runCommand(const std::string &command, const std::string &args) { if (Screenshot == command) { //just take a screen shot takeScreenshot(); } else if (ToggleRendermode == command) { toggleRenderMode(); } else if (Record == command) { mRecorder->startRecording(); } else if (Record.getInverseCommand() == command) { mRecorder->stopRecording(); } }
void MainCamera::runCommand(const std::string &command, const std::string &args) { if(Screenshot == command) { //just take a screen shot takeScreenshot(); } else if (ToggleFullscreen == command){ SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); } else if (ToggleRendermode == command) { toggleRenderMode(); } else if (Record == command) { mRecorder->startRecording(); } else if (Record.getInverseCommand() == command) { mRecorder->stopRecording(); } }
void ConsoleCommands::registerCommands(Console& console, AppService& appService, Menu& menu, GameSettings& gameSettings) { SDL_version sdlVersion; std::string verStr = D6_L("version"); // Print application info console.printLine(D6_L("\n===Application information===")); console.printLine(Format("{0} {1}: {2}") << APP_NAME << verStr << APP_VERSION); SDL_GetVersion(&sdlVersion); console.printLine(Format("SDL {0}: {1}.{2}.{3}") << verStr << sdlVersion.major << sdlVersion.minor << sdlVersion.patch); const SDL_version* mixVersion = Mix_Linked_Version(); console.printLine(Format("SDL_mixer {0}: {1}.{2}.{3}") << verStr << mixVersion->major << mixVersion->minor << mixVersion->patch); console.printLine(D6_L("Language: english")); // Set some console functions console.setLast(15); console.registerCommand("switch_render_mode", [&gameSettings](Console& con, const Console::Arguments& args) { toggleRenderMode(con, args, gameSettings); }); console.registerCommand("show_fps", [&gameSettings](Console& con, const Console::Arguments& args) { toggleShowFps(con, args, gameSettings); }); console.registerCommand("gl_info", openGLInfo); console.registerCommand("lang", language); console.registerCommand("volume", [&appService](Console& con, const Console::Arguments& args) { volume(con, args, appService.getSound()); }); console.registerCommand("rounds", [&gameSettings](Console& con, const Console::Arguments& args) { maxRounds(con, args, gameSettings); }); console.registerCommand("ghosts", [&gameSettings](Console& con, const Console::Arguments& args) { ghostMode(con, args, gameSettings); }); console.registerCommand("music", [&menu](Console& con, const Console::Arguments& args) { musicOnOff(con, args, menu); }); console.registerCommand("joy_scan", [&menu](Console& con, const Console::Arguments& args) { joyScan(con, args, menu); }); console.registerCommand("skin", [&menu](Console& con, const Console::Arguments& args) { loadSkin(con, args, menu); }); console.registerCommand("gun", enableWeapon); console.registerCommand("start_ammo_range", [&gameSettings](Console& con, const Console::Arguments& args) { ammoRange(con, args, gameSettings); }); }
void FieldViewerBase::key(unsigned char key, int x, int y) { _cmdManager.dispatchKey(key); _info.str(""); float dAlpha = 0.0f; float dwaveLength = 0.0f; float dBoost = 0.0f; GLfloat mat_emission[] = {0.5, 0.5, 0.5, 1.0}; GLfloat mat_no_emission[] = {0.0,0.0, 0.0, 0.0}; switch ( key ) { case 'j': MatlabFileAdapter::writeTexture2Matlabfile(_textures[_currenttexture],WIDTH,HEIGHT,DEPTH,"data.mat"); printf(" \rmatfile written"); break; case 'J': TextureFactory::statistics(_textures[_currenttexture],WIDTH,HEIGHT,DEPTH); break; case '4': toggleRenderMode(); break; case 'a': ++_alphablendmode%=10; blend(_alphablendmode); printf("alphablendmode %i \r",_alphablendmode); _info << "alphablendmode=" << _alphablendmode; break; case 'A': ++_alphablendfunction %=2; switchAlpha(); printf("alphablendfunction %i \r",_alphablendfunction); _info << "alphablendfunction=" << _alphablendfunction; glEnable(GL_ALPHA_TEST); break; case 'q': if (_alphatest <=1.0f) { if (_alphatest>0.9f ) dAlpha=0.001f; else dAlpha=0.01f; } _alphatest+=dAlpha; switchAlpha(); _info << "alphatest=" << _alphatest; printf("alphatest %f \r",_alphatest); break; case 'Q': if (_alphatest >=0.0f) { if (_alphatest < 0.1f) dAlpha=-0.001f; else dAlpha=-0.01f; } _alphatest+=dAlpha; switchAlpha(); _info << "alphatest=" << _alphatest; printf("alphatest %f \r",_alphatest); break; case 'w': glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); _alphablendfunction = 0; switchAlpha(); break; case 'W': glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); _alphablendfunction = 1; switchAlpha(); break; case '8': glEnable(GL_ALPHA_TEST); _alphablendfunction = 0; switchAlpha(); break; case '(': glDisable(GL_ALPHA_TEST); break; case 'z': z-=0.01f; _info << "z=" << z; printf("z %f \r",z); break; case 'Z': z+=0.01f; _info << "z=" << z; printf("z %f \r",z); break; case '*': _sources--; _info << "_sources=" << _sources; printf("_sources %i \r",_sources); break; case '+': _sources++; _info << "_sources=" << _sources; printf("_sources %i \r",_sources); break; case ' ': _animationRunning = !_animationRunning; break; } }
void GameState::update( float dt, Mouse* mouse ) { toggleRenderMode(); ship->update( dt ); for( int i = 0; i < (int)cannons.size(); i++ ) { cannons[i]->update( dt ); } updateCamera( dt ); if( ship->usingXray() && ship->getXray() == 0 ) { toggleRenderMode( true ); } vec3 shipPos = ship->transform.position(); // If the ship is where the tooth is, increase the score! if( shipPos.x >= -50 && shipPos.x <= 50 && shipPos.y >= -50 && shipPos.y <= 50 ) { score++; } DrawDebug::getInstance().drawDebugVector( shipPos, shipPos + ship->transform.forward() , vec3(0, 1, 1)); DrawDebug::getInstance().drawDebugVector( shipPos, shipPos + ship->transform.up() + vec3(0,0.001f,0), vec3(1, 1, 0)); DrawDebug::getInstance().drawDebugVector( shipPos, shipPos + ship->transform.right() , vec3(1, 0, 1)); // When in xray, invert the color so it stands out better vec4 color; if( renderSwap % 2 != 0 ) { color = vec4( 0, 0, 0, 1 ); } else { color = vec4( 1, 1, 1, 1 ); } text->drawText( L"HP:", vec3(0, 0, 0), TextJustify::LEFT, color ); text->drawText( std::to_wstring((int)ship->getHealth()), vec3( 150, 0, 0 ), TextJustify::LEFT, color ); text->drawText( L"XRAY:", vec3( 0, 50, 0 ), TextJustify::LEFT, color ); text->drawText( std::to_wstring( (int)ship->getXray() ), vec3( 150, 50, 0 ), TextJustify::LEFT, color ); text->drawText( L"SCORE:", vec3( 0, 100, 0 ), TextJustify::LEFT, color ); text->drawText( std::to_wstring( score ), vec3( 150, 100, 0 ), TextJustify::LEFT, color ); State::update(dt, mouse); CollisionManager::getInstance().update(dt); #if DEBUG DrawDebug& d = DrawDebug::getInstance(); //d.drawDebugSphere(vec3(0.5f, 0.5f, 0.5f), 0.5f); d.drawDebugVector(vec3(), vec3(1, 0, 0), vec3(1, 0, 0)); d.drawDebugVector(vec3(), vec3(0, 1, 0), vec3(0, 0, 1)); d.drawDebugVector(vec3(), vec3(0, .001f, 1), vec3(0, 1, 0)); //float c = 2 * PI; //vec3 v(1, 0, 0); //int div = 12; //for (int i = 0; i < div; i++) for (int j = 0; j < div; j++) d.drawDebugVector(vec3(), (vec3)(mat4::rotate(c * i / div, vec3(1, 0, 0)) * mat4::rotate(c * j / div, vec3(0, 1, 0)) * vec4(v))); CollisionManager::getInstance().draw(); #endif if( ship->getHealth() <= 0 ) { audioManager->stopSound(); CollisionManager::getInstance().clear(); StateManager::getInstance().xrayMode( false ); StateManager::getInstance().changeScene( SceneType::GAME_OVER ); } }
void ofApp::keyPressed(int key){ if(key>='0' && key<='9'){ cycle_disp_mode = int(key)-48; cout<<"cycle display mode: "<<cycle_disp_mode<<endl; } if(key=='a'){ mute = !mute; } /* if(key=='b'){ disp_buf = ofWrap(disp_buf+1, 0, 3); cout<<"display buffer: "<<disp_buf<<endl; }*/ if(key=='c'){ draw_offset.x = draw_offset.y = 0; } if(key=='d'){ disp_mode = (disp_mode+1)%display_sequence.size(); cout<<"display mode: "<<disp_mode<<endl; } if(key=='f'){ fullscreen = !fullscreen; ofSetFullscreen(fullscreen); } if(key=='h'){ usage(); } if(key=='i'){ integrator = 1-integrator; cout<<"integrator: "<<integrator<<endl; } if(key=='l'){ /*cout<<"reload shaders"<<endl; loadShaders(); */ } if(key=='p'){ disp_scale = ofWrap(disp_scale+1, 0, num_scales); cout<<"display scale: "<<disp_scale<<endl; } if(key=='s'){ save_frame = true; } if(key=='r'){ forward_graph->initFbos(); vwt->scramble(); } if(key==']'){ setResolution(fbo_params.width*2, fbo_params.height*2); cout<<"new resolution: "<<fbo_params.width<<" by "<<fbo_params.height<<endl; } if(key=='['){ if(fbo_params.width>1 && fbo_params.height>1) setResolution(fbo_params.width/2, fbo_params.height/2); cout<<"new resolution: "<<fbo_params.width<<" by "<<fbo_params.height<<endl; } if(key=='n'){ //for testing purposes setResolution(fbo_params.width, fbo_params.height); cout<<"call setResolution() with current resolution"<<endl; } if(key=='m'){ toggleRenderMode(); } if(key=='v'){ toggleVideoRecord(); } }