Made the camera behave nicely when approaching map edges.

This commit is contained in:
Sakse Dalum 2012-08-12 20:25:13 +02:00
parent f34d8106ef
commit 2b97af6526
2 changed files with 6 additions and 4 deletions

View File

@ -69,8 +69,10 @@ class Level(object):
screen_size = self.game.window.get_size()
self.camera_x = (self.player.x - screen_size[0] / 2 + 32)
self.camera_y = (self.player.y - screen_size[1] / 2 - 24)
self.camera_x = max(0, min(self.size[0] - screen_size[0],
(self.player.x - screen_size[0] / 2 + 32)))
self.camera_y = max(0, min(self.size[1] - screen_size[1] - 48,
(self.player.y - screen_size[1] / 2 - 24)))
def _blit_background(self, window):
window.blit(self.background, (0 - self.camera_x, 0 - self.camera_y))

View File

@ -44,8 +44,8 @@ import logic.colourboxes
class Level1(level.Level):
def __init__(self, game, graphics_dir, paused=False):
level.Level.__init__(self, game, graphics_dir, size=(64 * 100,
48 * 100),
level.Level.__init__(self, game, graphics_dir, size=(64 * 50,
48 * 50),
paused=paused)
self.solution = range(1, 6)