summaryrefslogtreecommitdiff
path: root/Level.cpp
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2010-11-27 23:29:00 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-11-27 23:29:00 +0000
commit34de0b2b50c3ab4dbb917ddcfda89d1eb12bc6be (patch)
treebd6a1e3e7670e044e0f7b8b841070cf09d2a9875 /Level.cpp
parenta00e29799a9fa4e8f140ef3f292f3200736fe957 (diff)
Level: Cope with there being no defined player start location
Diffstat (limited to 'Level.cpp')
-rw-r--r--Level.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/Level.cpp b/Level.cpp
index dc36e24..54fd8c6 100644
--- a/Level.cpp
+++ b/Level.cpp
@@ -8,6 +8,8 @@
#include "Platform.h"
Level::Level() {
+ startX = -1;
+ startY = -1;
}
void Level::changeLevel(int levelNo) {
@@ -33,6 +35,14 @@ void Level::changeLevel(int levelNo) {
// Read the map file (all level/player init should be done here, not above)
loadMap(levelNo);
+ if (startX < 0) {
+ startX = 0;
+ startY = 0;
+ }
+
+ player.setX(startX);
+ player.setY(startY);
+
cameraX = 0;
}
@@ -146,8 +156,8 @@ void Level::loadMap(int LevelNo) {
numPlatforms++;
} else if (type == 'P') {
// Set the player starting position
- player.setX((i % MAP_X) * TILE_SIZE);
- player.setY((i / MAP_X) * TILE_SIZE - player.getClip()->h);
+ startX = (i % MAP_X) * TILE_SIZE;
+ startY = (i / MAP_X) * TILE_SIZE - player.getClip()->h;
}
}