class Game(object): def __init__(self, width, height): self._egg = Egg(width, height,) self.clock = self._egg.clock self.physic_world = PhysicWorld(Rect(-width, -height, width * 3, height * 3)) self.state_manager = StateManager() self.sprite_factory = SpriteFactory() self._go_librarian = Librarian() Window().bgd = "grey" @self.renderer(Window().surface) def renderGame(surface): if self.physic_world.debug: color = self.physic_world.DEBUG_COLOR for b in self.physic_world.world: x, y = b.position for fixture in b: vertices = [(vx + x, vy + y) for vx, vy in fixture.shape.vertices] polygon(surface, vertices, color) displayFlip() return self.sprite_factory.draw(surface, Window().bgd) def getObjects(self, path="*"): return self._go_librarian.get(path) def delObjects(self, path): self._go_librarian.delete(path) def addObjects(self, path, objs): self._go_librarian.add(path, objs) def updateObjects(self, *args, **kargs): self._go_librarian.update(*args, **kargs) def getObjectsKeys(self): return self._go_librarian.keys def renderer(self, *args): return self._egg.Renderer(*args) def updateWorld(self, *args): self._egg.updateWorld(*args) def observeKeyboard(self, *args): self._egg.observeKeyboard(*args) def unobserveKeyboard(self, *args): self._egg.unobserveKeyboard(*args) def observeMouse(self, *args): self._egg.observeMouse(*args) def unobserveMouse(self, *args): self._egg.unobserveMouse(*args) def hatch(self, *args): self._egg.run(*args) def stop(self): self._egg.continue_pyguane = False
def __init__(self, width, height): self._egg = Egg(width, height,) self.clock = self._egg.clock self.physic_world = PhysicWorld(Rect(-width, -height, width * 3, height * 3)) self.state_manager = StateManager() self.sprite_factory = SpriteFactory() self._go_librarian = Librarian() Window().bgd = "grey" @self.renderer(Window().surface) def renderGame(surface): if self.physic_world.debug: color = self.physic_world.DEBUG_COLOR for b in self.physic_world.world: x, y = b.position for fixture in b: vertices = [(vx + x, vy + y) for vx, vy in fixture.shape.vertices] polygon(surface, vertices, color) displayFlip() return self.sprite_factory.draw(surface, Window().bgd)