summaryrefslogtreecommitdiff
path: root/Level.cpp
diff options
context:
space:
mode:
authorPhil Burton <whats_up_newbie@hotmail.com>2010-12-17 23:34:06 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-12-17 23:34:06 +0000
commit36f5cd0d0fbbf33b47af92cb51a4b78a217a54c1 (patch)
treea555ad09902b0269936a195a2537894a400a195a /Level.cpp
parent3dbcc5819d4762184292d6fcb05e05e73f4c721e (diff)
Level: Implement parallax background scrolling
Diffstat (limited to 'Level.cpp')
-rw-r--r--Level.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Level.cpp b/Level.cpp
index e39ab30..d956a78 100644
--- a/Level.cpp
+++ b/Level.cpp
@@ -96,8 +96,12 @@ void Level::move() {
}
void Level::draw(Screen *screen) {
+ int x = cameraX
+ * (SCREEN_WIDTH - background->w)
+ / (SCREEN_WIDTH - MAP_X*50);
+ int y = SCREEN_HEIGHT - background->h;
// Blit background
- screen->blit(0, 0, background);
+ screen->blit(x, y, background);
// If player is in the middle of the screen ...
if (player.getX() + cameraX > SCREEN_WIDTH / 2 - player.getClip()->w / 2 + player.getXVel()