void Client::tick(double frameTime) { handleInputEvents(); if (m_peer) { poll(); } if (m_world) { if (m_mainPlayer) { //NOTE: we send this shit regardless of input events..for obvious reasons. (aka fossils of a once living bug lie here ;) sendPlayerMovement(); sendPlayerMouseState(); } m_world->update(frameTime); if (m_quickBarMenu) { m_quickBarMenu->update(); } if (m_server) { if (m_physicsDebugRenderer) { m_debugMenu->setPhysicsWorldShapeCount(m_physicsDebugRenderer->shapeCount()); } } } }
void nodachi2D::displayNextScene_new() { sf::Vector2f playerPos; bool isOnFloor; int currentSpacialObject = 0; objects::SpacialObject* tmpObject = globalGameObjectManager_->nextSpacialObject( currentSpacialObject ); while( tmpObject != NULL ) { sf::Vector2f positionOfCurrentObject; b2Body* tmpB2Body = tmpObject->getB2Body(); positionOfCurrentObject = toolBox::b2Vec_To_sfVec_f(tmpB2Body->GetPosition(), physicsVisualsRatio, true); if( tmpObject->getSpacialObjectId().compare( "player" ) == 0 ) { playerPos = positionOfCurrentObject; twoDCam_.SetCenter(playerPos); appWindow_->SetView(twoDCam_); if(tmpObject->standsOnSomething()) { isOnFloor = true; } handleInputEvents(tmpObject); } objects::Animation* tmpAnim = tmpObject->getVisualAppearance()->getCurrentAnimation(); sf::Sprite* tmpSprite = tmpAnim->getNextFrame(); tmpSprite->Scale(spritesScale); tmpSprite->SetPosition( positionOfCurrentObject ); tmpSprite->SetRotation( (tmpB2Body->GetAngle() + tmpObject->getAngleOffsetForAnimation()) *(180/3.14159265f) ); appWindow_->Draw( (*tmpSprite) ); currentSpacialObject++; tmpObject = globalGameObjectManager_->nextSpacialObject( currentSpacialObject ); } if(isOnFloor) { sf::String onFloor("On Floor"); sf::Shape BGRect = sf::Shape::Rectangle(0.0,0.0,250.0,80.0,sf::Color::Black); onFloor.SetScale(2.0,2.0); onFloor.SetColor(sf::Color::Green); BGRect.SetPosition( playerPos.x+280, playerPos.y+320); onFloor.SetPosition( playerPos.x+280, playerPos.y+320); appWindow_->Draw(BGRect); appWindow_->Draw(onFloor); } appWindow_->Display(); appWindow_->Clear(); }
void nodachi2D::displayNextScene() { bool isOnFloor; sf::String onFloor("On Floor"); sf::Shape BGRect = sf::Shape::Rectangle(0.0,0.0,250.0,80.0,sf::Color::Black); onFloor.SetScale(2.0,2.0); onFloor.SetColor(sf::Color::Green); int i = 0; objects::SpacialObject* tmpObject = globalGameObjectManager_->nextSpacialObject( i ); while( tmpObject != NULL ) { b2Body* tmpB2Body = tmpObject->getB2Body(); b2Vec2 position = tmpB2Body->GetPosition(); float32 angle = tmpB2Body->GetAngle(); std::string objectID = tmpObject->getSpacialObjectId(); objects::Animation* tmpAnim = tmpObject->getVisualAppearance()->getCurrentAnimation(); sf::Sprite* tmpSprite = tmpAnim->getNextFrame(); if( objectID.compare( "player" ) == 0 ) { sf::Vector2f tmpPos; tmpPos.x = (position.x*physicsVisualsRatio); tmpPos.y = -(position.y*physicsVisualsRatio); twoDCam_.SetCenter(tmpPos); appWindow_->SetView(twoDCam_); if(tmpObject->standsOnSomething()) { isOnFloor = true; BGRect.SetPosition( tmpPos.x+280, tmpPos.y+320); onFloor.SetPosition( tmpPos.x+280, tmpPos.y+320); } handleInputEvents(tmpObject); } tmpSprite->Scale(spritesScale); tmpSprite->SetPosition( (position.x*physicsVisualsRatio) , -(position.y*physicsVisualsRatio) ); tmpSprite->SetRotation( (angle + tmpObject->getAngleOffsetForAnimation()) *(180/3.14159265f) ); appWindow_->Draw( (*tmpSprite) ); i++; tmpObject = globalGameObjectManager_->nextSpacialObject( i ); } if(isOnFloor) { appWindow_->Draw(BGRect); appWindow_->Draw(onFloor); } appWindow_->Display(); appWindow_->Clear(); }
void kajiya2D::handleEvents() { handleSystemEvents(); handleInputEvents(); }