From 2c50be65733ba936bf2850540551ac96f35b2aa1 Mon Sep 17 00:00:00 2001 From: Tamir Atias Date: Tue, 17 Apr 2012 20:41:55 +0300 Subject: [PATCH] [Fix] Flickery scrolling. --- src/Actor/Actor.cpp | 8 ++++++++ src/Actor/Actor.h | 2 ++ src/Main/Game.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Actor/Actor.cpp b/src/Actor/Actor.cpp index fc7828c..ef7fd02 100644 --- a/src/Actor/Actor.cpp +++ b/src/Actor/Actor.cpp @@ -117,3 +117,11 @@ float Actor::GetWidth(void) { float Actor::GetHeight(void) { return GetAnimation()->GetCurrentFrameSprite()->GetHeight(); } + +float Actor::GetMaxWidth(void) { + return GetAnimation()->GetMaxWidth(); +} + +float Actor::GetMaxHeight(void) { + return GetAnimation()->GetMaxHeight(); +} diff --git a/src/Actor/Actor.h b/src/Actor/Actor.h index 462af3f..e7707b0 100644 --- a/src/Actor/Actor.h +++ b/src/Actor/Actor.h @@ -37,6 +37,8 @@ public: float GetY(void) { return y; } float GetWidth(void); float GetHeight(void); + float GetMaxWidth(void); + float GetMaxHeight(void); void SetXY(float xArg, float yArg) { x = xArg; y = yArg; } diff --git a/src/Main/Game.cpp b/src/Main/Game.cpp index 1592f7e..36a032e 100644 --- a/src/Main/Game.cpp +++ b/src/Main/Game.cpp @@ -60,8 +60,8 @@ void Game::Render(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - float windowCenterX = ((float)windowWidth / 2.0f) - ((float)_player->GetWidth() / 2.0f); - float windowCenterY = ((float)windowHeight / 2.0f) - ((float)_player->GetHeight() / 2.0f); + float windowCenterX = ((float)windowWidth / 2.0f) - ((float)_player->GetMaxWidth() / 2.0f); + float windowCenterY = ((float)windowHeight / 2.0f) - ((float)_player->GetMaxHeight() / 2.0f); float xOffset = _player->GetX() - windowCenterX; float yOffset = _player->GetY() - windowCenterY;