diff options
author | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-11-27 23:14:27 +0000 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-11-27 23:14:27 +0000 |
commit | 4cc701b89af422e75057a3a13d0bb1745896d099 (patch) | |
tree | 689cae60f20742eb19d9dbb3b4dd44e09dc9e79b | |
parent | 9d69ea0b61b8c9147997874a7226f1abe99c4ed7 (diff) |
Level: Define the player starting position in the map file
-rw-r--r-- | Level.cpp | 11 | ||||
-rw-r--r-- | level01.map | 2 |
2 files changed, 5 insertions, 8 deletions
@@ -20,13 +20,6 @@ void Level::changeLevel(int levelNo) { Hazard hazard1; Platform platform1; - // Placing the player for fun/demonstration purposes - player.setX(0); - player.setY(0); - - // Checking where the player is for fun/demonstration purposes - std::cout << "Level::changeLevel(): player is at " << player.getX() << ", " << player.getY() << ".\n"; - // Load background image if (!(background = loadImage("space.png"))) std::cout << "Level::changeLevel: Error loading background image.\n"; @@ -151,6 +144,10 @@ void Level::loadMap(int LevelNo) { platform[numPlatforms].setClip(0, TILE_SIZE * (type - 1), 0, TILE_SIZE, TILE_SIZE); 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); } } diff --git a/level01.map b/level01.map index 0a06e97..7d7e88d 100644 --- a/level01.map +++ b/level01.map @@ -5,7 +5,7 @@ 00 00 00 00 00 00 00 00 00 00 00 01 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 02 02 02 00 02 00 00 00 00 00 00 00 00 00 00 00 02 02 02 00 02 00 00 00 00 00 00 00 00 00 00 00 02 02 02 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 02 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 00 05 05 05 05 05 05 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |