/// Time passed in seconds..! Will steer if inputFocus is true. void FirstPersonPlayerProperty::Process(int timeInMs) { if (inputFocus) ProcessInput(); }
void World::Update(float deltaTime, GLFWwindow* window) { ProcessInput(deltaTime, window); mCamera->Update(); }
static BOOLEAN DoBattle (BATTLE_STATE *bs) { extern UWORD nth_frame; RECT r; BYTE battle_speed; SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); #if defined (NETPLAY) && defined (NETPLAY_CHECKSUM) if (getNumNetConnections() > 0 && battleFrameCount % NETPLAY_CHECKSUM_INTERVAL == 0) { crc_State state; Checksum checksum; crc_init(&state); crc_processState (&state); checksum = (Checksum) crc_finish (&state); Netplay_NotifyAll_checksum ((uint32) battleFrameCount, (uint32) checksum); flushPacketQueues (); addLocalChecksum (battleFrameCount, checksum); } #endif ProcessInput (); // Also calls NetInput() #if defined (NETPLAY) && defined (NETPLAY_CHECKSUM) if (getNumNetConnections() > 0) { size_t delay = getBattleInputDelay(); if (battleFrameCount >= delay && (battleFrameCount - delay) % NETPLAY_CHECKSUM_INTERVAL == 0) { if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) { if (!verifyChecksums (battleFrameCount - delay)) { GLOBAL(CurrentActivity) |= CHECK_ABORT; resetConnections (ResetReason_syncLoss); } } } } #endif LockMutex (GraphicsLock); if (bs->first_time) { r.corner.x = SIS_ORG_X; r.corner.y = SIS_ORG_Y; r.extent.width = SIS_SCREEN_WIDTH; r.extent.height = SIS_SCREEN_HEIGHT; SetTransitionSource (&r); } BatchGraphics (); // Call the callback function, if set if (bs->frame_cb) bs->frame_cb (); RedrawQueue (TRUE); if (bs->first_time) { bs->first_time = FALSE; ScreenTransition (3, &r); } UnbatchGraphics (); UnlockMutex (GraphicsLock); if ((!(GLOBAL (CurrentActivity) & IN_BATTLE)) || (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { return FALSE; } battle_speed = HIBYTE (nth_frame); if (battle_speed == (BYTE)~0) { // maximum speed, nothing rendered at all TaskSwitch (); } else { SleepThreadUntil (bs->NextTime + BATTLE_FRAME_RATE / (battle_speed + 1)); bs->NextTime = GetTimeCounter (); } if ((GLOBAL (CurrentActivity) & IN_BATTLE) == 0) return FALSE; #ifdef NETPLAY battleFrameCount++; #endif return TRUE; }
bool CRemoteConsole :: Update( void *fd ) { if( !m_Socket ) return true; sockaddr_in recvAddr; string recvString; m_Socket->RecvFrom( (fd_set *)fd, &recvAddr, &recvString); if( !recvString.empty( ) ) { // erase newline if found if ( /*!recvString.empty( ) &&*/ recvString[recvString.size()-1] == '\n' ) recvString.erase( recvString.size()-1, 1 ); string cmd, payload, target = ""; SplitLine( recvString, cmd, payload, target ); CRemoteConsoleClient *client = NULL; for( vector<CRemoteConsoleClient *> :: iterator i = m_KnownClients.begin( ); i != m_KnownClients.end( ); i++ ) { if( AreEqual( (*i)->GetEndPoint( ), &recvAddr , true) ) { client = *i; // update LastReceived time client->Pong( ); break; } } if( !client ) { // client is not known yet if( recvAddr.sin_addr.s_addr == localhost.s_addr || ( !m_Password.empty( ) && cmd == "rcon_password" && payload == m_Password ) ) { // client has authed himself client = new CRemoteConsoleClient( m_Socket, recvAddr, -1, true ); client->Send( "[RCON] You are now authed" ); CONSOLE_Print("[RCON] User [" + client->GetIPString( ) + "] is now authorized"); m_KnownClients.push_back( client ); } else if( cmd == "rcon_broadcast" && payload.empty( ) ) { bool authorized = false; if( !authorized ) for( vector<CRemoteConsoleClient *> :: iterator i = m_KnownClients.begin( ); i != m_KnownClients.end( ); i++ ) { // only respond if IP is already connected and authed as rcon user if( AreEqual( (*i)->GetEndPoint( ), &recvAddr, false ) && (*i)->IsAuthed( ) ) { authorized = true; break; } } if( authorized || m_AnonymousBroadcast ) { if( m_GHost->m_CurrentGame ) m_GHost->m_CurrentGame->SendGame( m_Socket, recvAddr ); if( m_GHost->m_AdminGame && ( authorized || m_AnonymousAdminGame ) ) m_GHost->m_AdminGame->SendGame( m_Socket, recvAddr ); } else { // ban client for 5 seconds for not being authorized client = new CRemoteConsoleClient( m_Socket, recvAddr, 5 , false); m_KnownClients.push_back( client ); CONSOLE_Print("[RCON] User [" + client->GetIPString( ) + "] is not allowed to receive broadcasts"); } } else { // ban client for 5 seconds for sending an unkown command or the wrong password client = new CRemoteConsoleClient( m_Socket, recvAddr, 5, false ); m_KnownClients.push_back( client ); CONSOLE_Print("[RCON] User [" + client->GetIPString( ) + "] failed to authenticate"); } } else if( client->IsBanned( ) ) { // we have seen this user before, but he is banned CONSOLE_Print("[RCON] Banned user [" + client->GetIPString( ) + "] tried to execute command [" + recvString + "]"); } else if( !client->IsAuthed( ) ) { // we have seen this user before, but he hasn't provided the right login credentials yet if( !m_Password.empty( ) && cmd == "rcon_password" && payload == m_Password ) { client->Send( "[RCON] You are now authed" ); CONSOLE_Print("[RCON] User [" + client->GetIPString( ) + "] is now authorized"); client->SetAuthed( true ); } else { // ban client for 5 seconds for sending an unkown command or the wrong password client->Ban( 5 ); CONSOLE_Print("[RCON] User [" + client->GetIPString( ) + "] failed to authenticate"); } } else if( cmd == "rcon_password" ) { // client is already authed and tries to auth again, just tell him he is now authed client->Send( "[RCON] You are now authed" ); } else if( cmd == "rcon_sendlobbychat" ) { if ( m_GHost->m_CurrentGame && !m_GHost->m_CurrentGame->GetGameLoading( ) && !m_GHost->m_CurrentGame->GetGameLoaded( ) ) m_GHost->m_CurrentGame->SendAllChat( payload ); } else if( cmd == "rcon_kick" ) { if ( m_GHost->m_CurrentGame && !m_GHost->m_CurrentGame->GetGameLoading( ) && !m_GHost->m_CurrentGame->GetGameLoaded( ) ) { CGamePlayer *player = m_GHost->m_CurrentGame->GetPlayerFromName( payload, true ); if( player ) { player->SetDeleteMe( true ); player->SetLeftReason( m_GHost->m_Language->WasKickedByPlayer( "Remote Console" ) ); player->SetLeftCode( PLAYERLEAVE_LOBBY ); m_GHost->m_CurrentGame->OpenSlot( m_GHost->m_CurrentGame->GetSIDFromPID( player->GetPID( ) ), false ); } } } // disabled for now /*else if( cmd == "rcon_gamedetails" ) { if( m_GHost->m_CurrentGame && !m_GHost->m_CurrentGame->GetGameLoading( ) && !m_GHost->m_CurrentGame->GetGameLoaded( ) ) client->Send( "[RCON] Game details: " + m_GHost->m_CurrentGame->GetGameDetails( ) ); else client->Send( "[RCON] Game details: no game in lobby" ); }*/ else if( !cmd.empty( ) ) { // this is a legitimate user, do what he says ProcessInput( cmd, payload, target, client ); } } for( vector<CRemoteConsoleClient *> :: iterator i = m_KnownClients.begin( ); i != m_KnownClients.end( ); ) { //(*i)->AutoBroadcast( m_GHost->m_CurrentGame, m_GHost->m_AdminGame ); if( GetTime( ) > (*i)->GetLastReceived( ) + m_KeepAliveTime + m_Timeout && (*i)->IsAuthed( ) ) { // user has not responded in time, de-auth him (*i)->SetAuthed( false ); (*i)->Send( "[RCON] Your session timed out" ); CONSOLE_Print("[RCON] User [" + (*i)->GetIPString( ) + "] timed out"); } else if( GetTime( ) > (*i)->GetLastReceived( ) + m_KeepAliveTime && GetTime( ) > (*i)->GetLastPinged( ) + m_KeepAliveInterval ) { // user has not sent an command in quite some time, send him a keep-alive packet (containing the word "PING") (*i)->Ping( ); } if ( !(*i)->IsAuthed( ) && !(*i)->IsBanned( ) ) { delete *i; i = m_KnownClients.erase( i ); } else i++; } return false; }
void Game::GameLoop() { // Game is going: handle all rendering! Listens for player input to update game. // Compute the FoV GameMap.Field->computeFov(player.x, player.y, 0, true, FOV_DIAMOND); // basic FoV // Loop through all turfs and draw them std::vector<Turf*> Turfs = GameMap.TurfRange(player.cam_x, player.cam_y, 44); // Apply gradual fade as appropriate if(player.viewinginventory) { fade -= 0.02f; if(fade < 0.0f) { fade = 0.0f; } } else { fade = 1.0f; } for(int i = 0; i < Turfs.size(); i++) { Turf* turfchosen = Turfs[i]; // select the turf // Calculate the scrolling offset int x = (turfchosen->x - player.cam_x) + VIEW_WIDTH / 2; int y = (turfchosen->y - player.cam_y) + (VIEW_HEIGHT-(UI_BOTTOM_DIV-(VIEW_HEIGHT/2))) / 2; if(y > UI_BOTTOM_DIV) // do not draw anything on the bottom 16 cells continue; // Draw the turf if( GameMap.Field->isInFov(turfchosen->x, turfchosen->y) && (x >= 0 && y >= 0) && (x < VIEW_WIDTH && y < VIEW_HEIGHT) ) { if(fade != 1.0f) { TCODConsole::root->setDefaultForeground(TCODColor::lerp(TCODColor::darkGrey, turfchosen->color, fade)); } else { TCODConsole::root->setDefaultForeground(turfchosen->color); } if(turfchosen->c_symbol > 0) { TCODConsole::root->putChar(x, y, turfchosen->c_symbol); } else { TCODConsole::root->putChar(x, y, turfchosen->symbol); } // Draw all visible entities for(int j = 0; j < turfchosen->contents.size(); j++) { Entity* entity = turfchosen->contents[j]; if(entity->symbol != ' ') { if(fade != 1.0f) { TCODConsole::root->setDefaultForeground(TCODColor::lerp(TCODColor::darkGrey, entity->color, fade)); } else { TCODConsole::root->setDefaultForeground(entity->color); } if(entity->c_symbol > 0) { TCODConsole::root->putChar(x, y, entity->c_symbol); } else { TCODConsole::root->putChar(x, y, entity->symbol); } } } } } // Draw the hud! DrawHud(false); // draw the borders and whatnot DrawHud(true); // draw the messages, stats, etc // Draw the inventory if necessary DrawInv(); if(debug_a_code > 0) { TCODConsole::root->putChar(5, 5, debug_a_code); // just for easy character mapping } TCODConsole::flush(); // apply changes // Handle user input: TCOD_key_t key = {TCODK_NONE,0}; TCOD_mouse_t mouse; TCODSystem::checkForEvent((TCOD_event_t)(TCOD_EVENT_KEY_PRESS|TCOD_EVENT_MOUSE),&key,&mouse); ProcessInput(key, mouse); // Release unnecessary gui pointers if(_inventoryConsole != NULL && !player.viewinginventory) { delete _inventoryConsole; _inventoryConsole = NULL; } if(_inventoryInfo != NULL && (!player.viewinginventory || player.selecteditem == NULL)) { delete _inventoryInfo; _inventoryInfo = NULL; } // Clear the screen: TCODConsole::root->clear(); }
void IApp::GameLoop(void) { SLOG(App_GameLoop, SeverityInfo) << std::endl; // Is this a Console Only game loop? bool anConsoleOnly = mProperties.Get<bool>("bWindowConsole"); // Clock used in restricting Update loop to a fixed rate sf::Clock anUpdateClock; #if (SFML_VERSION_MAJOR < 2) // Restart/Reset our Update clock anUpdateClock.Reset(); // When do we need to update next (in seconds)? float anUpdateNext = anUpdateClock.GetElapsedTime(); #else // Clock used in calculating the time elapsed since the last frame sf::Clock anFrameClock; // Restart/Reset our Update clock anUpdateClock.restart(); // When do we need to update next (in milliseconds)? sf::Int32 anUpdateNext = anUpdateClock.getElapsedTime().asMilliseconds(); #endif // Make sure we have at least one state active if(mStateManager.IsEmpty()) { // Exit with an error since there isn't an active state Quit(StatusAppInitFailed); } // Loop while IsRunning returns true #if (SFML_VERSION_MAJOR < 2) while(IsRunning() && !mStateManager.IsEmpty() && (mWindow.IsOpened() || anConsoleOnly)) #else while(IsRunning() && !mStateManager.IsEmpty() && (mWindow.isOpen() || anConsoleOnly)) #endif { // Get the currently active state IState& anState = mStateManager.GetActiveState(); // Count the number of sequential UpdateFixed loop calls Uint32 anUpdates = 0; // Process any available input ProcessInput(anState); // Make note of the current update time #if (SFML_VERSION_MAJOR < 2) float anUpdateTime = anUpdateClock.GetElapsedTime(); #else sf::Int32 anUpdateTime = anUpdateClock.getElapsedTime().asMilliseconds(); #endif // Process our UpdateFixed portion of the game loop while((anUpdateTime - anUpdateNext) >= mUpdateRate && anUpdates++ < mMaxUpdates) { // Let the current active state perform fixed updates next anState.UpdateFixed(); // Let the StatManager perfom its updates mStatManager.UpdateFixed(); //ILOG() << "IApp::UpdateFixed() anUpdates=" << anUpdates // << ", anUpdateTime=" << anUpdateTime << ", anUpdateNext=" << anUpdateNext // << ", mUpdateRate=" << mUpdateRate << ", anUpdateActual=" #if (SFML_VERSION_MAJOR < 2) // << (anUpdateClock.GetElapsedTime() - anUpdateTime) << std::endl; #else // << (anUpdateClock.getElapsedTime().asMilliseconds() - anUpdateTime) << std::endl; #endif // Compute the next appropriate UpdateFixed time anUpdateNext += mUpdateRate; } // while((anUpdateTime - anUpdateNext) >= mUpdateRate && anUpdates <= mMaxUpdates) // Let the current active state perform its variable update #if (SFML_VERSION_MAJOR < 2) anState.UpdateVariable(mWindow.GetFrameTime()); #else // Convert to floating point value of seconds for SFML 2.0 anState.UpdateVariable(anFrameClock.restart().asSeconds()); #endif // Let the current active state draw stuff anState.Draw(); // Let the StatManager perform its drawing mStatManager.Draw(); #if (SFML_VERSION_MAJOR < 2) // Display Render window to the screen mWindow.Display(); #else // Display Render window to the screen mWindow.display(); #endif // Give the state manager a chance to delete any pending states mStateManager.Cleanup(); } // while(IsRunning() && !mStates.empty() && (mWindow.isOpen() || anConsoleOnly)) }
//// // Process the stuff of the player when playing in a normal level void CPlayer::processInLevel() { StatusBox(); if (pdie) dieanim(); else { inhibitwalking = false; inhibitfall = false; // when walking through the exit door don't show keen's sprite past // the door frame (so it looks like he walks "through" the door) if(!pfrozentime) { if (!level_done) ProcessInput(); else ProcessExitLevel(); } setDir(); if(!level_done) { getgoodies(); raygun(); keencicle(); } if(!pfrozentime) { if(!pjumping) { Walking(); // if we bump against a wall all inertia stops if (xinertia > 0 && blockedr) xinertia = 0; if (xinertia < 0 && blockedl) xinertia = 0; WalkingAnimation(); } } checkSolidDoors(); InertiaAndFriction_X(); if(!level_done) { TogglePogo_and_Switches(); JumpAndPogo(); } // Check collision with other objects performCollisions(); checkObjSolid(); if(!inhibitfall) Playerfalling(); } if(pSupportedbyobject) blockedd = true; }
void PathSepSetting::lineEdit_textChanged(const QString &text) { ProcessInput(text); }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_I2C1_Init(); MX_USART1_UART_Init(); MX_TIM16_Init(); MX_TIM17_Init(); /* USER CODE BEGIN 2 */ g_config = g_config_default; #ifdef USE_I2C g_i2c = I2cMaster_Init(&hi2c1); InitializeDisplay(g_i2c); I2cEEPROM_Init(&g_eeprom, g_i2c, EEPROMADDR, 1, 8); #endif #ifdef USE_SERIAL UsartInit(&huart1); #endif #if defined(USE_I2C) && defined(USE_LCD) I2cLcd_Clear(&g_lcd); I2cLcd_PrintStr(&g_lcd, "Hello"); #endif #if defined(USE_SERIAL) && defined(USE_EEPROM) #define TESTSIZE 2048/8 HAL_StatusTypeDef st; uint8_t i2cBuffer[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* for(uint16_t i = 0; i < TESTSIZE; i += sizeof(i2cBuffer)) { if(!(i & (sizeof(i2cBuffer)-1))) { st = I2cEEPROM_Write(&g_eeprom, i, i2cBuffer, sizeof(i2cBuffer)); } } for (uint16_t i = 0; i < TESTSIZE; ++i) { if(!(i & (sizeof(i2cBuffer)-1))) { st = I2cEEPROM_Read(&g_eeprom, i, i2cBuffer, sizeof(i2cBuffer)); UsartSendStr("\r\n", 1); UsartPrintUint(i, 4, 1); UsartSendStr(" ", 1); } UsartPrintByte(i2cBuffer[i&(sizeof(i2cBuffer)-1)], 2, 1); UsartSendStr(" ", 1); } UsartSendStr("\r\n", 1); for(uint16_t i = 0; i < TESTSIZE; i += sizeof(i2cBuffer)) { if(!(i & (sizeof(i2cBuffer)-1))) { for(uint16_t j = 0; j<sizeof(i2cBuffer); ++j) i2cBuffer[j] = i+j; st = I2cEEPROM_Write(&g_eeprom, i, i2cBuffer, sizeof(i2cBuffer)); } } for (uint16_t i = 0; i < TESTSIZE; ++i) { if(!(i & (sizeof(i2cBuffer)-1))) { st = I2cEEPROM_Read(&g_eeprom, i, i2cBuffer, sizeof(i2cBuffer)); UsartSendStr("\r\n", 1); UsartPrintUint(i, 4, 1); UsartSendStr(" ", 1); } UsartPrintByte(i2cBuffer[i&(sizeof(i2cBuffer)-1)], 2, 1); UsartSendStr(" ", 1); } UsartSendStr("\r\n", 1); */ { LIVECONFIG config; if (I2cEEPROM_Read(&g_eeprom, EESTART, &config, sizeof(config)) == HAL_OK) { I2cMaster_WaitCallback(g_i2c); if (config.magic == 0xA5) g_config = config; } } for (uint16_t i = 0; i < TESTSIZE; ++i) { if(!(i & (sizeof(i2cBuffer)-1))) { st = I2cEEPROM_Read(&g_eeprom, i, i2cBuffer, sizeof(i2cBuffer)); UsartSendStr("\r\n", 1); UsartPrintUint(i, 4, 1); UsartSendStr(" ", 1); } UsartPrintByte(i2cBuffer[i&(sizeof(i2cBuffer)-1)], 2, 1); UsartSendStr(" ", 1); } UsartSendStr("\r\n", 1); #endif HAL_TIM_IC_Start_IT(&htim16, TIM_CHANNEL_1); HAL_TIM_IC_Start_IT(&htim17, TIM_CHANNEL_1); HAL_UART_Receive_IT(&huart1, g_lineBuffer, sizeof(g_lineBuffer)); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { if (g_lineReceived) { ProcessInput(&g_config, (char*) g_lineBuffer); //DisplayInput(&i2clcd); g_lineReceived = 0; HAL_UART_Receive_IT(&huart1, g_lineBuffer, sizeof(g_lineBuffer)); } if(g_statuses[0].trigger) { DisplayResults(0); g_statuses[0].trigger = 0; } if(g_statuses[1].trigger) { DisplayResults(1); g_statuses[1].trigger = 0; } /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
bool CChat::HandleKeyInput( CGUIKeyEventArgs keyArgs ) { // Are we not connected? if( !pCore->GetNetworkModule() || !pCore->GetNetworkModule()->IsConnected() ) return false; // Is the input focused on the GUI? if( pCore->GetGUI()->GetCEGUI()->IsInputEnabled() ) return false; // Are we enabling the chat? if( (keyArgs.codepoint == 116 || keyArgs.codepoint == 96 || keyArgs.codepoint == 84 || keyArgs.codepoint == 229) && !IsInputVisible() ) { // Set the input visible SetInputVisible( true ); // Lock game controls LockGameControls( true ); return true; } // Is the input not visible? if( !IsInputVisible() ) return false; // switch( keyArgs.codepoint ) { case VK_RETURN: { // Disable the input SetInputVisible( false ); // Restore game controls LockGameControls( false ); // Process the input ProcessInput(); // Clear the input text ClearInputText(); break; } case VK_ESCAPE: { // Disable the input SetInputVisible( false ); // Restore game controls LockGameControls( false ); break; } case VK_BACK: { // Get the input text length size_t sLen = m_strInput.GetLength(); // Do we have any input? if( sLen > 0 ) { // Resize the input m_strInput.Resize( sLen - 1 ); } break; } default: { // Get the current input len size_t sInputLen = m_strInput.GetLength(); // Have we got any room left? if( sInputLen < MAX_MESSAGE_LEN ) { // Add the character to the end of the input text m_strInput += static_cast< char >( keyArgs.codepoint ); } break; } } return false; }
//Ham chua noi dung Update cac su kien //Trong ham chua Ham kiem tra Ban phim void clsMapple::Update(clsInput *input, clsCamera *camera, list<clsObject*> *l_StaticObj, list<clsObject*> *l_DynamicObj) { if(m_x<camera->rectCamera.left) m_x = camera->rectCamera.left; if(m_x+m_width>camera->rectCamera.right) m_x = camera->rectCamera.right-m_width; ProcessInput(input); if(!m_Dev) { ResetRect(0,65,8,42); m_Arrow->ResetRect(3,9,8,60); } else { ResetRect(0,65,0,50); m_Arrow->ResetRect(3,9,8,60); } //ResetRect(); if(m_Light) if(m_Develop->Delay()) m_Develop->Next(); if(m_Develop->m_frameNow==m_Develop->m_frameTotal-1) { //m_Develop->SetIndex(0); m_Light = false; } if(m_exp>KN[m_level-1]) { m_exp = 0; m_Light = true; m_dame+=20; m_level++; if(m_level==3) { m_Dev = true; } m_health = M[m_level-1]; } Moving(l_StaticObj,l_DynamicObj); //if(m_Jumping) // Jump(); if(m_Arrow->m_alive) { m_Arrow->Update(input, camera,l_StaticObj,l_DynamicObj); /*if(m_Arrow->m_x > 1000||m_Arrow->m_x < 0) m_Arrow->m_alive=false;*/ } if(m_life<=0) gamelose = true; clsObject *temp; list<clsObject*>::iterator i; for(i=l_DynamicObj->begin();i!=l_DynamicObj->end();i++) { temp = *i; if(clsCollision::KiemTraVaCham(m_Rect,temp->m_Rect)&& temp->m_ID!=4) { if(!isProtected&&temp->m_alive&&m_Action!=DIE) { if(m_health - temp->m_dame >0) { isProtected=true; waitProtected = 0; waitRender=0; m_health -= temp->m_dame; } else { m_health = 0; m_Action = DIE; m_life--; } break; } } if(clsCollision::KiemTraVaCham(m_Rect,temp->m_Rect)&&(temp->m_ID==4)) { if(m_Rect.left>=(temp->m_Rect.left-10)&&m_Rect.right<=(temp->m_Rect.right+10)) isNext = true; } else isNext = false; } if(isProtected) { if(m_timeProtcted->CallWaiting()) { waitProtected++; waitRender++; if(waitRender>2) { waitRender--; isRender = !isRender; } if(waitProtected>50) { isRender = true; isProtected = false; } } } switch(m_Action) { case STAND: if(m_Maple->Delay()) m_Maple->Next(4,5); if(m_Maple->m_frameNow==4) m_Maple->m_delayTime->SetTimePerImage(500); break; case MOVE: if(m_Maple->Delay()) m_Maple->Next(0,3); if(m_Mapple2->Delay()) m_Mapple2->Next(0,3); break; case JUMP: m_Maple->SetIndex(8); m_Mapple2->SetIndex(4); //Jump(); break; case SHOOT: if(!m_Dev) { if(m_Maple->Delay()) m_Maple->Next(9,11); if(m_Maple->m_frameNow==11) { m_Action = m_oldAction; if(m_Jumping==false) m_Action = STAND; } } else { if(m_Mapple2->Delay()) m_Mapple2->Next(7,9); if(m_Mapple2->m_frameNow==7) { m_Action = m_oldAction; if(m_Jumping==false) m_Action = STAND; } } break; case CLIMB: /*if(m_Mapple2->Delay()) m_Mapple2->Next(5,6);*/ break; case DIE: if(m_Die->m_frameNow==m_Die->m_frameTotal-1) { if(m_life>0) { m_alive = true; m_Action = STAND; m_health = m_revivehealth; isProtected=true; waitProtected = 0; waitRender=0; m_Light = true; } } if(m_Die->Delay()) m_Die->Next(); break; default: break; } }
void Inflator::Put(const byte *inString, unsigned int length) { LazyPutter lp(m_inQueue, inString, length); ProcessInput(false); }
//----------------------------------------------------------------------------- // Name : FrameAdvance () (Private) // Desc : Called to signal that we are now rendering the next frame. //----------------------------------------------------------------------------- void CGameApp::FrameAdvance() { static TCHAR FrameRate[ 50 ]; static TCHAR TitleBuffer[ 255 ]; // Advance the timer m_Timer.Tick( 60 ); // Skip if app is inactive if ( !m_bActive ) return; // Get / Display the framerate if ( m_LastFrameRate != m_Timer.GetFrameRate() ) { m_LastFrameRate = m_Timer.GetFrameRate( FrameRate, 50 ); sprintf_s( TitleBuffer, _T("Game : %s"), FrameRate ); SetWindowText( m_hWnd, TitleBuffer ); } // End if Frame Rate Altered if(StartGame == true) { SetCursor( NULL ); // Poll & Process input devices ProcessInput(); // Collision detection between game objects BricksExist=false; CollisionDetection(); if(BricksExist == false) { Vec2 brickPos; brickPos.x = START_BRICK_POS_X; brickPos.y = START_BRICK_POS_Y; countBricks = 0; countGifts = 0; nrBricks = 0; // delete objects from previous level for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { countBricks++; } } for(int cBricks = 0; cBricks <= countBricks; cBricks++) { for(auto it2 = m_vGameObjects.begin(); it2 != m_vGameObjects.end(); ++it2) { CGameObject * pGameObj = it2->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { m_vGameObjects.erase(it2); break; } } } for(auto it = m_vGameObjectsGift.begin(); it != m_vGameObjectsGift.end(); ++it) { CGameObject * pGameObj = it->get(); countGifts++; } for(int cGifts = 0; cGifts <= countGifts; cGifts++) { for(auto it2 = m_vGameObjectsGift.begin(); it2 != m_vGameObjectsGift.end(); ++it2) { CGameObject * pGameObj = it2->get(); m_vGameObjectsGift.erase(it2); break; } } // load new objects m_pBall.lock()->myVelocity.x = 0; m_pBall.lock()->myVelocity.y = 0; m_pBall.lock()->myPosition.x = m_pPlayer.lock()->myPosition.x; m_pBall.lock()->myPosition.y = m_nViewHeight - m_pBall.lock()->GetHeight() - m_pPlayer.lock()->GetHeight() - ONE; FollowPlayer = true; UnstoppableBall = false; StickyBar = false; MoveBall = false; SystemParametersInfo(SPI_SETMOUSESPEED, NULL, (void*)10, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ballPos.x = 0; if(ShrinkBar == true) { ShrinkBar = false; m_pPlayer.lock()->Normal_Bar(); } nrLevel++; level.LoadBricks(nrLevel); level.RandomBricks("-ud"); string::iterator it; for(it = level.bricks.begin(); it < level.bricks.end(); it++) { if(*it == '-') { continue; } auto pBrick = std::make_shared<Brick>(*it); m_vGameObjects.push_back(pBrick); } for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectType() == GOT_Brick) { for(std::size_t levelbricks = 0; levelbricks < level.bricks.size(); levelbricks++) { if(level.bricks[nrBricks] == '-') { brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } else { nrBricks++; break; } nrBricks++; } pGameObj->Init(Vec2(brickPos.x, brickPos.y)); brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } } if(level.Winner == true) { LevelChange = false; } else { LevelChange = true; } } // Animate the game objects AnimateObjects(); } // Drawing the game objects DrawObjects(); }
void PaginatedWindow::DisplayPages(bool fullScreen) { s_inputFocus.push_back(this); // trailer is single line prompt for (next)/(end) const int trailerSize = 1; // compute page height m_itemsPerPage = m_height - m_header.size() - trailerSize; m_itemsPerPage = min((int) m_lines.size(), m_itemsPerPage); int originalWidth = m_width; int orignalHeight = m_height; int originalXOffset = m_xOffset; int originalYOffset = m_yOffset; int leftBorder = 0; if (fullScreen) { m_pageWidth = m_width; m_pageHeight = m_height; } else { m_pageHeight = m_itemsPerPage + m_header.size() + trailerSize; // compute page width m_pageWidth = m_nextPrompt.size(); m_pageWidth = max((int)m_donePrompt.size(), m_pageWidth); for (auto & line : m_header) { if ((int)line.m_text.size() > m_width) line.m_text.resize(m_width); m_pageWidth = max((int)line.m_text.size(), m_pageWidth); } for (auto & line : m_lines) { if ((int)line.m_text.size() > m_width) line.m_text.resize(m_width); m_pageWidth = max((int)line.m_text.size(), m_pageWidth); } if (m_pageWidth + 10 <= m_width) { leftBorder = 2; m_xOffset = m_width - m_pageWidth - leftBorder; m_width = m_pageWidth + leftBorder; } else { m_xOffset = 0; } m_yOffset = 0; m_height = m_pageHeight; } CellAttribute defaultAttribute; m_cancelled = false; m_done = false; m_itemOffset = 0; while (!m_done) { int itemsRemaining = m_lines.size() - m_itemOffset; m_lastPage = (itemsRemaining <= m_itemsPerPage); int itemCount = m_lastPage ? itemsRemaining : m_itemsPerPage; m_cellBuffer->Clear(); int y = 0; for (auto & line : m_header) { CellAttribute attribute(line.m_color, line.m_attribute); m_cellBuffer->Putstr(leftBorder, y++, attribute, line.m_text.c_str()); } for (int i = 0; i < itemCount; i++) { auto & line = m_lines[i + m_itemOffset]; CellAttribute attribute(line.m_color, line.m_attribute); m_cellBuffer->Putstr(leftBorder, y++, attribute, line.m_text.c_str()); } auto & bottomPrompt = m_lastPage ? m_donePrompt : m_nextPrompt; m_cellBuffer->Putstr(leftBorder, y++, defaultAttribute, bottomPrompt.c_str()); if (!fullScreen) m_height = y; Curs(leftBorder + bottomPrompt.size(), y - 1); ProcessInput(wt_nhgetch()); } if (!fullScreen) { m_xOffset = originalXOffset; m_yOffset = originalYOffset; m_width = originalWidth; m_height = orignalHeight; } s_inputFocus.remove(this); }