[Change] Clamped boundaries to the window width and height.

This commit is contained in:
Rtch90 2011-12-23 19:51:24 +00:00
parent 261bed63d3
commit 17b03fdb16
5 changed files with 19 additions and 9 deletions

View File

@ -161,7 +161,6 @@ void Game::Render(void) {
} else {
_ingameMenu.Render();
}
SDL_Flip(screen);
}

View File

@ -57,6 +57,8 @@ void Player::HandleInput(void) {
void Player::Update(void) {
Move();
// For now The camera will be static.
//SetCamera();
}

View File

@ -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;
}
/*

View File

@ -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);

View File

@ -24,6 +24,7 @@ public:
~Map(void);
void Load(const string filename);
void Update(void);
void Render(void);
bool GetTileSolidity(int xArg, int yArg);