Fixes.
This commit is contained in:
commit
536df5f329
|
@ -69,20 +69,25 @@ 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))
|
||||||
|
|
||||||
def _sorted_objs(self, objs=None):
|
def _sorted_objs(self, objs=None):
|
||||||
objs = self.objects if objs is None else objs
|
return sorted(self.objects if objs is None else objs,
|
||||||
return sorted(objs, key=lambda obj: (obj.y + obj.z))
|
key=lambda obj: (obj.y + obj.z))
|
||||||
|
|
||||||
def draw(self, window):
|
def draw(self, window):
|
||||||
self._blit_background(window)
|
self._blit_background(window)
|
||||||
|
|
||||||
for obj in self._sorted_objs():
|
for obj in self._sorted_objs():
|
||||||
obj.draw(window)
|
try:
|
||||||
|
obj.draw(window)
|
||||||
|
except IndexError:
|
||||||
|
print("Skipping frames ...")
|
||||||
|
|
||||||
self.darkness.draw(window)
|
self.darkness.draw(window)
|
||||||
|
|
|
@ -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 * 40,
|
||||||
48 * 100),
|
48 * 40),
|
||||||
paused=paused)
|
paused=paused)
|
||||||
|
|
||||||
self.solution = range(1, 6)
|
self.solution = range(1, 6)
|
||||||
|
@ -54,30 +54,28 @@ class Level1(level.Level):
|
||||||
|
|
||||||
self.task_completions = [0, 0, 0]
|
self.task_completions = [0, 0, 0]
|
||||||
|
|
||||||
self.dimensions = 50, 50
|
|
||||||
|
|
||||||
self.set_darkness(0)
|
self.set_darkness(0)
|
||||||
|
|
||||||
for i in range(self.dimensions[0]):
|
for i in range(self.size[0] / 64):
|
||||||
for j in range(self.dimensions[1]):
|
for j in range(self.size[1] / 48):
|
||||||
self.tiles.append(
|
self.tiles.append(
|
||||||
tile.Tile(self, i*64, j*48, self.imgs['ground1']))
|
tile.Tile(self, i*64, j*48, self.imgs['ground1']))
|
||||||
|
|
||||||
self.player.set_pos(64 * 15, 48 * 30)
|
self.player.set_pos(64 * 15, 48 * 30)
|
||||||
self.player.set_init_pos()
|
self.player.set_init_pos()
|
||||||
|
|
||||||
for i in range(self.dimensions[0]):
|
for i in range(self.size[0] / 64):
|
||||||
if not i % 3:
|
if not i % 3:
|
||||||
self.objects.append(block.Block(self, i * 64,
|
self.objects.append(block.Block(self, i * 64,
|
||||||
48 * 3,
|
48 * 3,
|
||||||
self.imgs['wall_outside'],
|
self.imgs['wall_outside'],
|
||||||
width=3))
|
width=3))
|
||||||
self.objects.append(block.InvisBlock(self, i * 64,
|
self.objects.append(block.InvisBlock(self, i * 64,
|
||||||
(self.dimensions[1]) * 48))
|
self.size[1] * 48))
|
||||||
for i in range(self.dimensions[1]):
|
for i in range(self.size[1] / 48):
|
||||||
self.objects.append(block.InvisBlock(self, - 64,
|
self.objects.append(block.InvisBlock(self, - 64,
|
||||||
i * 48))
|
i * 48))
|
||||||
self.objects.append(block.InvisBlock(self, self.dimensions[0] * 64,
|
self.objects.append(block.InvisBlock(self, self.size[0],
|
||||||
i * 48))
|
i * 48))
|
||||||
|
|
||||||
|
|
||||||
|
@ -507,7 +505,7 @@ class Level1(level.Level):
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
self.objects.append(
|
self.objects.append(
|
||||||
CompletionBlock(self, 64 * (door_x - 6 + i), 48 * 4,
|
CompletionBlock(self, 64 * (door_x - 5 + i), 48 * 4,
|
||||||
self.solution[i], i + 1))
|
self.solution[i], i + 1))
|
||||||
|
|
||||||
# DRAW THE BACKGROUND
|
# DRAW THE BACKGROUND
|
||||||
|
|
Loading…
Reference in New Issue