From 36f5cd0d0fbbf33b47af92cb51a4b78a217a54c1 Mon Sep 17 00:00:00 2001 From: Phil Burton Date: Fri, 17 Dec 2010 23:34:06 +0000 Subject: Level: Implement parallax background scrolling --- Level.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Level.cpp') 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() -- cgit v1.2.3