Made the camera behave nicely when approaching map edges.
This commit is contained in:
parent
f34d8106ef
commit
2b97af6526
|
@ -69,8 +69,10 @@ class Level(object):
|
||||||
|
|
||||||
|
|
||||||
screen_size = self.game.window.get_size()
|
screen_size = self.game.window.get_size()
|
||||||
self.camera_x = (self.player.x - screen_size[0] / 2 + 32)
|
self.camera_x = max(0, min(self.size[0] - screen_size[0],
|
||||||
self.camera_y = (self.player.y - screen_size[1] / 2 - 24)
|
(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):
|
def _blit_background(self, window):
|
||||||
window.blit(self.background, (0 - self.camera_x, 0 - self.camera_y))
|
window.blit(self.background, (0 - self.camera_x, 0 - self.camera_y))
|
||||||
|
|
|
@ -44,8 +44,8 @@ import logic.colourboxes
|
||||||
|
|
||||||
class Level1(level.Level):
|
class Level1(level.Level):
|
||||||
def __init__(self, game, graphics_dir, paused=False):
|
def __init__(self, game, graphics_dir, paused=False):
|
||||||
level.Level.__init__(self, game, graphics_dir, size=(64 * 100,
|
level.Level.__init__(self, game, graphics_dir, size=(64 * 50,
|
||||||
48 * 100),
|
48 * 50),
|
||||||
paused=paused)
|
paused=paused)
|
||||||
|
|
||||||
self.solution = range(1, 6)
|
self.solution = range(1, 6)
|
||||||
|
|
Loading…
Reference in New Issue