GLObjectStatus* GLObject::doPhysics() { if (lastTimeStamp == -1) { updateCurrentTime(); } int oldtime = lastTimeStamp; updateCurrentTime(); return doPhysics(lastTimeStamp - oldtime); }
/* * Game execution: Gets input events, processes game logic and draws sprites on the screen */ void Game::gameLoop() { _gameState = GameState::PLAY; while (_gameState != GameState::EXIT) { //Start synchronization between refresh rate and frame rate _fpsLimiter.startSynchronization(); //Process the input information (keyboard and mouse) processInput(); //Execute the player actions (keyboard and mouse) executePlayerCommands(); //Update the game status doPhysics(); //Draw the objects on the screen renderGame(); //Force synchronization _fpsLimiter.forceSynchronization(); } }
void PhysicsDoer::start() { if (QThread::currentThread() != m_thread) { bool success; success = QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection); Q_ASSERT(success); return; } m_physics_timer = new QTimer(this); bool success; success = connect(m_physics_timer, SIGNAL(timeout()), this, SLOT(doPhysics())); Q_ASSERT(success); m_physics_time.start(); m_physics_timer->start(1000 / c_physics_fps); }
int calc_schizo( Uint32 steps ) { //Finish? if ( spGetInput()->button[SP_BUTTON_START] ) return 1; //Ingame controls if (do_control_stuff()) //result is non zero => level change levelFade = -FADE_TIME; if ( levelFade > 0 ) //Fade in { levelFade -= steps; if (levelFade < 0) levelFade = 0; else return 0; } if ( levelFade < 0 ) //Fade out { levelFade += steps; if (levelFade > 0) { levelFade = FADE_TIME; clearPhysics(); deleteLevel((*levelPointer)); (*levelPointer) = loadLevel(get_saved_level()); createPhysicsFromLevel((*levelPointer)); } else return 0; } //Physics int i; for (i = 0; i < steps; i++) doPhysics(*levelPointer); //Visualization stuff rotation+=steps*16; updateLevelObjects(); updateLevelSprites((*levelPointer),steps); calcCamera((*levelPointer),steps); return 0; }
/* * Game execution: Gets input events, processes game logic and draws sprites on the screen */ void Game::gameLoop() { _gameState = GameState::PLAY; while (_gameState != GameState::EXIT) { if (_network.GetNetworkState() == NetworkState::SAYINGHELLO) { _network.SayHello(); } int positionSquare = aSquares[_network.GetIdSquare()].GetPosition(); _network.SendMove(positionSquare,_inputState, _inputStateList); Receiving(); //Update the game physics doPhysics(); //Detect keyboard and/or mouse events _graphic.detectInputEvents(); //Execute the player commands executePlayerCommands(); //Render game renderGame(); } }
void ball::update(float dt) { doPhysics(dt); doTurnRed(dt); }