diff options
author | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-11-26 16:42:18 +0000 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-11-26 16:42:18 +0000 |
commit | 63418dfa8adac1f9eee3c8357b54454d0bc0b0d5 (patch) | |
tree | c5e095691aa1ece32dfdb04482c484dc27835e3f | |
parent | 7e046277d6a04e006d9653eda0a2b0990a454c2d (diff) |
Use a constant for the player's left/right move amount
-rw-r--r-- | Level.cpp | 2 | ||||
-rw-r--r-- | intensemarcus.h | 1 | ||||
-rw-r--r-- | main.cpp | 8 |
3 files changed, 6 insertions, 5 deletions
@@ -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; @@ -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; } } |