From 63418dfa8adac1f9eee3c8357b54454d0bc0b0d5 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 26 Nov 2010 16:42:18 +0000 Subject: Use a constant for the player's left/right move amount --- Level.cpp | 2 +- intensemarcus.h | 1 + main.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Level.cpp b/Level.cpp index 7da0bf4..0cecd50 100644 --- a/Level.cpp +++ b/Level.cpp @@ -82,7 +82,7 @@ void Level::draw(Screen *screen) { screen->blit(player.getX(), player.getY(), player.image, player.getClip()); // Scroll level - if (player.getX() == 0 || player.getX() >= SCREEN_WIDTH - MARCUS_WIDTH - 10) { + if (player.getX() == 0 || player.getX() >= SCREEN_WIDTH - MARCUS_WIDTH - MOVE_AMOUNT) { if (player.getXVel() < 0 || player.getXVel() > 0) cameraX -= player.getXVel(); } diff --git a/intensemarcus.h b/intensemarcus.h index 01d7268..f4ceac5 100644 --- a/intensemarcus.h +++ b/intensemarcus.h @@ -17,6 +17,7 @@ const int ORIENT_RIGHT = 2; const int ORIENT_LEFT = 3; const int GRAVITY = 3; const int JUMP_STRENGTH = 40; +const int MOVE_AMOUNT = 10; const int MAP_X = 48; const int MAP_Y = 12; const int TILE_SIZE = 50; diff --git a/main.cpp b/main.cpp index 81e5896..4b22a5d 100644 --- a/main.cpp +++ b/main.cpp @@ -37,10 +37,10 @@ int main(int argc, char* args[]) { // Adjust player velocity switch (event.key.keysym.sym) { case SDLK_LEFT: - level.player.incXVel(-10); + level.player.incXVel(-MOVE_AMOUNT); break; case SDLK_RIGHT: - level.player.incXVel(10); + level.player.incXVel(MOVE_AMOUNT); break; case SDLK_UP: level.player.jump(); @@ -50,10 +50,10 @@ int main(int argc, char* args[]) { // Adjust player velocity switch (event.key.keysym.sym) { case SDLK_LEFT: - level.player.incXVel(10); + level.player.incXVel(MOVE_AMOUNT); break; case SDLK_RIGHT: - level.player.incXVel(-10); + level.player.incXVel(-MOVE_AMOUNT); break; } } -- cgit v1.2.3