[Change] Clamped boundaries to the window width and height.
This commit is contained in:
parent
261bed63d3
commit
17b03fdb16
@ -161,7 +161,6 @@ void Game::Render(void) {
|
|||||||
} else {
|
} else {
|
||||||
_ingameMenu.Render();
|
_ingameMenu.Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Flip(screen);
|
SDL_Flip(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@ void Player::HandleInput(void) {
|
|||||||
|
|
||||||
void Player::Update(void) {
|
void Player::Update(void) {
|
||||||
Move();
|
Move();
|
||||||
|
|
||||||
|
// For now The camera will be static.
|
||||||
//SetCamera();
|
//SetCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,9 @@ void Character::Move(void) {
|
|||||||
tileX = ((x + (w / 2)) / TILE_WIDTH);
|
tileX = ((x + (w / 2)) / TILE_WIDTH);
|
||||||
tileY = ((y + (h / 2)) / TILE_HEIGHT);
|
tileY = ((y + (h / 2)) / TILE_HEIGHT);
|
||||||
|
|
||||||
if((x < 0) || (x + w) > levelWidth) 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(CheckTileCollisions()) x -= xVel;
|
||||||
if(CheckEntityCollisions()) x -= xVel;
|
if(CheckEntityCollisions()) x -= xVel;
|
||||||
if(CheckCharacterCollisions()) x -= xVel;
|
if(CheckCharacterCollisions()) x -= xVel;
|
||||||
@ -145,7 +147,9 @@ void Character::Move(void) {
|
|||||||
tileX = ((x + (w / 2)) / TILE_WIDTH);
|
tileX = ((x + (w / 2)) / TILE_WIDTH);
|
||||||
tileY = ((y + (h / 2)) / TILE_HEIGHT);
|
tileY = ((y + (h / 2)) / TILE_HEIGHT);
|
||||||
|
|
||||||
if((y < 0) || (y + h) > levelHeight) 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(CheckTileCollisions()) y -= yVel;
|
||||||
if(CheckEntityCollisions()) y -= yVel;
|
if(CheckEntityCollisions()) y -= yVel;
|
||||||
if(CheckCharacterCollisions()) y -= yVel;
|
if(CheckCharacterCollisions()) y -= yVel;
|
||||||
|
@ -128,6 +128,10 @@ void Map::Load(const string filename) {
|
|||||||
//character->Load(filename);
|
//character->Load(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::Update(void) {
|
||||||
|
// Update the map so we can render when camera moves.
|
||||||
|
}
|
||||||
|
|
||||||
void Map::Render(void) {
|
void Map::Render(void) {
|
||||||
int xOrig = (camera.x / TILE_WIDTH);
|
int xOrig = (camera.x / TILE_WIDTH);
|
||||||
int yOrig = (camera.y / TILE_HEIGHT);
|
int yOrig = (camera.y / TILE_HEIGHT);
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
~Map(void);
|
~Map(void);
|
||||||
|
|
||||||
void Load(const string filename);
|
void Load(const string filename);
|
||||||
|
void Update(void);
|
||||||
void Render(void);
|
void Render(void);
|
||||||
|
|
||||||
bool GetTileSolidity(int xArg, int yArg);
|
bool GetTileSolidity(int xArg, int yArg);
|
||||||
|
Loading…
Reference in New Issue
Block a user