Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    def __init__(self, game,):
        super(PlayingState, self).__init__(lock=1000)
        self._timer = 0
        self._game = game
        setMouseVisible(False)
        
        #build the loading screen
        loading_label = Label(0, 0, 28, u"Loading...", kind="widget.label.loading", color=BLUE)
        self._game.sprite_factory.showSpritesFromKind("widget.label.loading", True)
        
        surface = Window().surface
        surface.fill(GREY)
        loading_label_pos = (surface.get_rect().centerx - loading_label.width / 2,
                             surface.get_rect().centery - loading_label.height / 2)
        surface.blit(loading_label.sprite.image, loading_label_pos)
        displayFlip()
        
        #load game data
        tiles = TileMap("media/map_data.dump").tiles
        mousse = Mousse("renard", "00", (20, 210), 100)
        
        vegetables = ["carotte", "navet"]
        veg_spawners = []
        for i in range(1, 24):
            veg_spawners.append(VegSpawner("poulailler_%s" % (vegetables[randint(0, len(vegetables) - 1)]),
                                            (90 + randint(30, 720), 170 + randint(-80, 320)), 98))
        

        self._game.addObjects("map", tiles)
        self._game.addObjects("characters", mousse)
        self._game.addObjects("items", veg_spawners)

        
        self._camera = Camera()
        self._game.addObjects("camera", self._camera)

        self._game.observeKeyboard(mousse.keyboard, self.keyboard)
        #destroy the loading screen
        self._game.sprite_factory.delSpritesFromKind("widget.label.loading")
        Window().bgd = BROWN_EARTH
        displayFlip()