diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp index 353c29b..79aed62 100644 --- a/src/Unuk/Game.cpp +++ b/src/Unuk/Game.cpp @@ -161,7 +161,6 @@ void Game::Render(void) { } else { _ingameMenu.Render(); } - SDL_Flip(screen); } diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp index 53fc485..9e64eaa 100644 --- a/src/Unuk/Player.cpp +++ b/src/Unuk/Player.cpp @@ -57,6 +57,8 @@ void Player::HandleInput(void) { void Player::Update(void) { Move(); + + // For now The camera will be static. //SetCamera(); } diff --git a/src/libUnuk/Character.cpp b/src/libUnuk/Character.cpp index 97173ea..5bc75af 100644 --- a/src/libUnuk/Character.cpp +++ b/src/libUnuk/Character.cpp @@ -136,19 +136,23 @@ void Character::Move(void) { tileX = ((x + (w / 2)) / TILE_WIDTH); tileY = ((y + (h / 2)) / TILE_HEIGHT); - if((x < 0) || (x + w) > levelWidth) x -= xVel; - if(CheckTileCollisions()) x -= xVel; - if(CheckEntityCollisions()) x -= xVel; - if(CheckCharacterCollisions()) x -= xVel; + // While we have a static camera, ensure that we do not go out + // of the camera boundaries. + if((x < 0) || (x + w) > levelWidth || (x + w) > SCREEN_WIDTH) x -= xVel; + if(CheckTileCollisions()) x -= xVel; + if(CheckEntityCollisions()) x -= xVel; + if(CheckCharacterCollisions()) x -= xVel; y += yVel; tileX = ((x + (w / 2)) / TILE_WIDTH); tileY = ((y + (h / 2)) / TILE_HEIGHT); - if((y < 0) || (y + h) > levelHeight) y -= yVel; - if(CheckTileCollisions()) y -= yVel; - if(CheckEntityCollisions()) y -= yVel; - if(CheckCharacterCollisions()) y -= yVel; + // While we have a static camera, ensure that we do not go out + // of the camera boundaries. + if((y < 0) || (y + h) > levelHeight || (y + h) > SCREEN_HEIGHT) y -= yVel; + if(CheckTileCollisions()) y -= yVel; + if(CheckEntityCollisions()) y -= yVel; + if(CheckCharacterCollisions()) y -= yVel; } /* diff --git a/src/libUnuk/Map.cpp b/src/libUnuk/Map.cpp index 0fe928d..460c763 100644 --- a/src/libUnuk/Map.cpp +++ b/src/libUnuk/Map.cpp @@ -128,6 +128,10 @@ void Map::Load(const string filename) { //character->Load(filename); } +void Map::Update(void) { + // Update the map so we can render when camera moves. +} + void Map::Render(void) { int xOrig = (camera.x / TILE_WIDTH); int yOrig = (camera.y / TILE_HEIGHT); diff --git a/src/libUnuk/Map.h b/src/libUnuk/Map.h index e1582a2..c09570b 100644 --- a/src/libUnuk/Map.h +++ b/src/libUnuk/Map.h @@ -24,6 +24,7 @@ public: ~Map(void); void Load(const string filename); + void Update(void); void Render(void); bool GetTileSolidity(int xArg, int yArg);