Entity* GameCreate( Entity* pParentEnt ) { Config* config = Config::GetInstance(); GetApp()->setContinueBtn( true ); char path[256]; sprintf( path, "%s%s", GetApp()->getResourceInstance()->getItem( GetApp()->getResolutionType(), RES_TYPE_MENU, RES_ID_NONE ).c_str(), s_gameMenuXml ); XMLMenu* parser = new XMLMenu( path, pParentEnt, &GameOnSelect, config->getLangPack() ); parser->Read(); Entity* pBG = parser->createEntities(); delete parser; Entity* pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGE_GAMEOVER_SPLASH ); if( pEnt ) { pEnt->GetVar( "visible" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGEBUTTON_GAMEPLAY_DOWN ); if( pEnt ) { pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGEBUTTON_GAMEPLAY_LEFT ); if( pEnt ) { pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGEBUTTON_GAMEPLAY_RIGHT ); if( pEnt ) { pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGEBUTTON_GAMEPLAY_ROTATE ); if( pEnt ) { pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } GetApp()->setGame( true ); FadeInEntity( pBG, true, 1000 ); config->FreeInstance(); return pBG; }
//testing accelerometer readings. To enable the test, search below for "ACCELTEST" //Note: You'll need to look at the debug log to see the output. (For android, run PhoneLog.bat from RTBareBones/android) void App::OnAccel(VariantList *pVList) { if ( int(pVList->m_variant[0].GetFloat()) != MESSAGE_TYPE_GUI_ACCELEROMETER) return; CL_Vec3f v = pVList->m_variant[1].GetVector3(); LogMsg("Accel: %s", PrintVector3(v).c_str()); v.x = v.x * kFilteringFactor + v.x * (1.0f - kFilteringFactor); v.y = v.y * kFilteringFactor + v.y * (1.0f - kFilteringFactor); v.z = v.z * kFilteringFactor + v.z * (1.0f - kFilteringFactor); // Compute values for the three axes of the acceleromater float x = v.x - v.x; float y = v.y - v.x; float z = v.z - v.x; //Compute the intensity of the current acceleration if (sqrt(x * x + y * y + z * z) > 2.0f) { Entity *pEnt = GetEntityRoot()->GetEntityByName("jumble"); if (pEnt) { //GetAudioManager()->Play("audio/click.wav"); VariantList vList(CL_Vec2f(), pEnt); pEnt->GetFunction("OnButtonSelected")->sig_function(&vList); } LogMsg("Shake!"); } }
Entity* SoundCreate( Entity* pParentEnt ) { GameState::GetCurrentState()->SetSubState( GS_Menu::k_substate_none ); char path[256]; sprintf( path, "%s%s", GetApp()->getResourceInstance()->getItem( GetApp()->getResolutionType(), RES_TYPE_MENU, RES_ID_NONE ).c_str(), s_soundMenuXml ); Config* config = Config::GetInstance(); XMLMenu* parser = new XMLMenu( path, pParentEnt, &SoundOnSelect, config->getLangPack() ); parser->Read(); Entity* pBG = parser->createEntities(); delete parser; std::string cbEffects = GUI_CHECKBOX_CHECKBOX_EFFECTS; std::string cbMusic = GUI_CHECKBOX_CHECKBOX_MUSIC; std::string cbVibration = GUI_CHECKBOX_CHECKBOX_VIBRATION; Entity *pEnt = GetEntityRoot()->GetEntityByName( cbEffects ); if( pEnt ) { SetCheckBoxChecked( pEnt, !config->getSoundEffects(), false ); pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( cbMusic ); if( pEnt ) { SetCheckBoxChecked( pEnt, !config->getMusic(), false ); pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } pEnt = GetEntityRoot()->GetEntityByName( cbVibration ); if( pEnt ) { SetCheckBoxChecked( pEnt, !config->getVibration(), false ); pEnt->GetComponentByName( "Button2D" )->GetVar( "repeatDelayMS" )->Set( uint32( 0 ) ); } FadeInEntity( pBG, true, 1000 ); config->FreeInstance(); return pBG; }
void nodes::init() { entity_ = GetEntityRoot()->AddEntity(new Entity("typewriter")); //entity_->GetFunction("next_char")->sig_function.connect(boost::bind(&typewriter::next_char, this, _1)); r_batch_nodes = new RenderBatcher(); node_ = new Surface("interface/node.rttex"); node_visited_ = new Surface("interface/node_clear.rttex"); node_station_ = new Surface("interface/eco_node.rttex"); ship_ = new Surface("interface/ship.rttex"); set_nodes(0); }
void GS_GamePlay::RenderState() { if( m_tetris->isEndGame() ) { Entity* pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGE_GAMEOVER_SPLASH ); if( pEnt ) { pEnt->GetVar( "visible" )->Set( uint32( 1 ) ); pEnt->GetVar( "rotation" )->Set( Variant( SinGamePulseByMS(1500)*0.5f ) ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_IMAGE_GAMEPLAY_MARK ); if( pEnt ) { pEnt->GetVar( "visible" )->Set( uint32( 0 ) ); } } m_tetris->Run(); }
void GS_GamePlay::UpdateState( int frameTime ) { Entity* pEnt = GetEntityRoot()->GetEntityByName( GUI_TEXT_LEVEL_LABEL_BOX ); if( pEnt ) { pEnt->GetComponentByName( "TextRender" )->GetVar( "text" )->Set( m_tetris->getLevel() ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_TEXT_SCORE_LABEL_BOX ); if( pEnt ) { pEnt->GetComponentByName( "TextRender" )->GetVar( "text" )->Set( m_tetris->getScore() ); } pEnt = GetEntityRoot()->GetEntityByName( GUI_TEXT_LINES_LABEL_BOX ); if( pEnt ) { pEnt->GetComponentByName( "TextRender" )->GetVar( "text" )->Set( m_tetris->getLines() ); } }
void fade_out_in::init() { frames_ = 0; bg_1_ = new Surface("interface/fade_1.rttex"); bg_2_ = new Surface("interface/fade_2.rttex"); bg_3_ = new Surface("interface/fade_3.rttex"); bg_4_ = new Surface("interface/fade_4.rttex"); bg_5_ = new Surface("interface/fade_5.rttex"); bg_6_ = new Surface("interface/fade_6.rttex"); entity_ = GetEntityRoot()->AddEntity(new Entity("fade_out_in")); start = 100; fade_out_ = false; fade_in_ = false; }
bool BaseApp::Init() { m_gameTimer.Reset(); GetEntityRoot()->SetName("root"); if (m_bInitted) { LogMsg("Why are we initting more than once?"); return true; } m_bInitted = true; CHECK_GL_ERROR(); PrintGLString("Version", GL_VERSION); PrintGLString("Vendor", GL_VENDOR); PrintGLString("Renderer", GL_RENDERER); PrintGLString("Extensions", GL_EXTENSIONS); InitializeGLDefaults(); GLint depthbits; glGetIntegerv(GL_DEPTH_BITS, &depthbits); LogMsg("GL depth buffer: %d bit", depthbits); CHECK_GL_ERROR(); if (GetAudioManager()) { GetAudioManager()->Init(); } return true; }
void typewriter::init() { entity_ = GetEntityRoot()->AddEntity(new Entity("typewriter")); entity_->GetFunction("next_char")->sig_function.connect(boost::bind(&typewriter::next_char, this, _1)); }
void App::Update() { //game can think here. The baseApp::Update() will run Update() on all entities, if any are added. The only one //we use in this example is one that is watching for the Back (android) or Escape key to quit that we setup earlier. BaseApp::Update(); if (!m_bDidPostInit) { //stuff I want loaded during the first "Update" m_bDidPostInit = true; //for android, so the back key (or escape on windows) will quit out of the game Entity *pEnt = GetEntityRoot()->AddEntity(new Entity); EntityComponent *pComp = pEnt->AddComponent(new CustomInputComponent); //tell the component which key has to be hit for it to be activated pComp->GetVar("keycode")->Set(uint32(VIRTUAL_KEY_BACK)); //attach our function so it is called when the back key is hit pComp->GetFunction("OnActivated")->sig_function.connect(1, boost::bind(&App::OnExitApp, this, _1)); //nothing will happen unless we give it input focus pEnt->AddComponent(new FocusInputComponent); //ACCELTEST: To test the accelerometer uncomment below: (will print values to the debug output) //SetAccelerometerUpdateHz(25); //default is 0, disabled //GetBaseApp()->m_sig_accel.connect(1, boost::bind(&App::OnAccel, this, _1)); //TRACKBALL/ARCADETEST: Uncomment below to see log messages on trackball/key movement input pComp = pEnt->AddComponent(new ArcadeInputComponent); GetBaseApp()->m_sig_arcade_input.connect(1, boost::bind(&App::OnArcadeInput, this, _1)); //these arrow keys will be triggered by the keyboard, if applicable AddKeyBinding(pComp, "Left", VIRTUAL_KEY_DIR_LEFT, VIRTUAL_KEY_DIR_LEFT); AddKeyBinding(pComp, "Right", VIRTUAL_KEY_DIR_RIGHT, VIRTUAL_KEY_DIR_RIGHT); AddKeyBinding(pComp, "Up", VIRTUAL_KEY_DIR_UP, VIRTUAL_KEY_DIR_UP); AddKeyBinding(pComp, "Down", VIRTUAL_KEY_DIR_DOWN, VIRTUAL_KEY_DIR_DOWN); AddKeyBinding(pComp, "Shift", VIRTUAL_KEY_CONTROL, VIRTUAL_KEY_CONTROL); AddKeyBinding(pComp, "Fire", VIRTUAL_KEY_CONTROL, VIRTUAL_KEY_GAME_FIRE); //INPUT TEST - wire up input to some functions to manually handle. AppInput will use LogMsg to //send them to the log. (Each device has a way to view a debug log in real-time) GetBaseApp()->m_sig_input.connect(&AppInput); /* //file handling test, if TextScanner.h is included at the top.. TextScanner t; t.m_lines.push_back("Testing 123"); t.m_lines.push_back("F**k ya'll!"); t.m_lines.push_back("Whoopsopsop!"); LogMsg("Saving file..."); t.SaveFile("temp.txt"); TextScanner b; b.LoadFile("temp.txt"); b.DumpToLog(); */ } //game is thinking. if (g_game->game_state_ == 1) //we update the objects { g_game->update(); } }