From 4cc701b89af422e75057a3a13d0bb1745896d099 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 27 Nov 2010 23:14:27 +0000 Subject: Level: Define the player starting position in the map file --- Level.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Level.cpp') diff --git a/Level.cpp b/Level.cpp index c4da3b2..a787e94 100644 --- a/Level.cpp +++ b/Level.cpp @@ -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); } } -- cgit v1.2.3