summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2010-11-26 16:42:18 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-11-26 16:42:18 +0000
commit63418dfa8adac1f9eee3c8357b54454d0bc0b0d5 (patch)
treec5e095691aa1ece32dfdb04482c484dc27835e3f
parent7e046277d6a04e006d9653eda0a2b0990a454c2d (diff)
Use a constant for the player's left/right move amount
-rw-r--r--Level.cpp2
-rw-r--r--intensemarcus.h1
-rw-r--r--main.cpp8
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;
}
}