Made the camera follow the robot.
This commit is contained in:
@@ -24,10 +24,24 @@
|
||||
A generic level.
|
||||
"""
|
||||
|
||||
import player
|
||||
|
||||
class Level(object):
|
||||
def __init__(self, graphics_dir, paused=False):
|
||||
def __init__(self, game, graphics_dir, paused=False):
|
||||
self.__dict__.update(locals())
|
||||
|
||||
self.tiles = []
|
||||
self.objects = []
|
||||
self.imgs = {}
|
||||
|
||||
self.load()
|
||||
|
||||
self.camera_x = 0
|
||||
self.camera_y = 0
|
||||
|
||||
self.player = player.Player(self, 0, 0)
|
||||
self.objects.append(self.player)
|
||||
|
||||
def restart(self):
|
||||
pass
|
||||
|
||||
@@ -36,6 +50,10 @@ class Level(object):
|
||||
for obj in self.objects:
|
||||
obj.update(e, t, dt)
|
||||
|
||||
screen_size = self.game.window.get_size()
|
||||
self.camera_x = self.player.x - screen_size[0] / 2
|
||||
self.camera_y = self.player.y - screen_size[1] / 2
|
||||
|
||||
def draw(self, window):
|
||||
for tile in self.tiles:
|
||||
tile.draw(window)
|
||||
|
||||
Reference in New Issue
Block a user