Пример #1
0
class Level(Controller):
    """docstring for LevelController"""
    def __init__(self, window, keys, levelname):
        super(Level, self).__init__(window, keys)
        self.tiled_map = load_pyglet(levelname, invert_y=True)
        self.view = LevelView(self.window.width, self.window.height, self.tiled_map)
        self.collition_layer = self.tiled_map.get_layer_by_name('collision')
        self.startLocation = self.tiled_map.get_object_by_name('Starting Location')
        self.exitLocation = self.tiled_map.get_object_by_name('Exit Location')

        self.setupPlayer(self.startLocation)

    def draw(self):
        self.view.draw()

    def setupPlayer(self, startLocation):
        self.mainCharacter = Entity(PlayerInputComponent(self.keys), PhysicsComponent(self), GraphicsComponent(self.view, "test.png"))
        self.mainCharacter.x = startLocation.x
        self.mainCharacter.y = self.window.height - startLocation.y - startLocation.height + 96
        self.mainCharacter.width = 32
        self.mainCharacter.height = 32

    def update(self):
        self.mainCharacter.update()

    def handleKeys(self):
        pass

    def handleMouse(self, x, y, button, modifier):
        pass
Пример #2
0
    def __init__(self, window, keys, levelname):
        super(Level, self).__init__(window, keys)
        self.tiled_map = load_pyglet(levelname, invert_y=True)
        self.view = LevelView(self.window.width, self.window.height, self.tiled_map)
        self.collition_layer = self.tiled_map.get_layer_by_name('collision')
        self.startLocation = self.tiled_map.get_object_by_name('Starting Location')
        self.exitLocation = self.tiled_map.get_object_by_name('Exit Location')

        self.setupPlayer(self.startLocation)