void Paddle::HandleCollision(sbe::Rect const& bound) { // if we collid with top/bottom make sure we do the diff // of the remaining space (otherwise it looks ugly!) if (y() < bound.y()) { int diff = y() - bound.y(); UpdateY(-diff); } else if (y() + height() > bound.height()) { int diff = y() + height() - bound.height(); UpdateY(-diff); } }
void Paddle::UpdatePosition(sbe::World::Ptr const& world) { if (paused_) return; sbe::Rect const& bound = world->Boundary(); UpdateVelocity(); UpdateY(vel_y_); HandleCollision(bound); }
void Screen::Update() { UpdateY(); float lWalkingSpeed = gPlayerMovementSpeed; if(GetAsyncKeyState(VK_LSHIFT) & 0x8000 && mState != falling) lWalkingSpeed = gPlayerMovementSpeed*2; KeyBoardMovement(lWalkingSpeed, mDeltaTime); mWorldHandler->Update(mDeltaTime); mParticleHandler->Update(mDeltaTime, mGameTime); UpdateSunWVP(); mGameTimer->Tick(); mDeltaTime = mGameTimer->GetDeltaTime(); mGameTime = mGameTimer->GetGameTime(); //tror det är skillnaden i position i z ledet som ska in som offset, might be wrong, kör på 50 sålänge GetCamera().BuildViewReflection(50.0f); GetCamera().RebuildView(); }