From ff9f965f9290d5e9985c695556c3164a6a751e75 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 3 Dec 2010 12:38:03 +0000 Subject: Code cleanups --- Level.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Level.cpp b/Level.cpp index 6f453e3..11cb3d4 100644 --- a/Level.cpp +++ b/Level.cpp @@ -35,6 +35,7 @@ void Level::changeLevel(int levelNo) { // Read the map file (all level/player init should be done here, not above) loadMap(levelNo); + // Cope for no defined start position if (startX < 0) { startX = 0; startY = 0; @@ -70,9 +71,8 @@ void Level::move() { } } - if (rect.x >= 0 && rect.x <= SCREEN_WIDTH - rect.w - 32) { + if (rect.x >= 0 && rect.x <= SCREEN_WIDTH - rect.w - 32) player.setX(rect.x); - } // Player y-axis movement rect.y = player.getY() + player.getYVel(); @@ -111,14 +111,13 @@ void Level::draw(Screen *screen) { // Scroll level if (player.getX() < -player.getXVel() || player.getX() >= SCREEN_WIDTH - - player.getClip()->w - 32 - MOVE_AMOUNT) { + - player.getClip()->w - 32 - MOVE_AMOUNT) if (player.getXVel() < 0 || player.getXVel() > 0) cameraX -= player.getXVel(); - } // Don't let the camera move to before the start of the level if (cameraX > 0) - cameraX = 0; + cameraX = 0; // Draw each platform... for (int i = 0; i < numPlatforms; i++) { -- cgit v1.2.3