Exemplo n.º 1
0
    def to_drawable(self, x, y, batch, square_size, color):
        """A city is represented as square containing a smaller square.
        """
        shapes = []
        r = super().to_drawable(x, y, batch, square_size, color)
        shapes.append(r)

        w = h = square_size * .4
        offset = square_size * .5
        r_inner = Rectangle(x + offset,
                            y + offset,
                            w,
                            h,
                            color=(0, 0, 0),
                            batch=batch)
        r_inner.anchor_position = (w * .5, h * .5)
        r_inner.opacity = 128
        shapes.append(r_inner)

        return shapes
Exemplo n.º 2
0
 def _rebuild_hotbar(self):
     self._hotbar_sprites = []
     self.hotbar_background.x = self.hotbar_x
     self.hotbar_background.y = self.hotbar_y
     self.hotbar_background.width = self.size_x
     self.hotbar_background.height = self.size_y
     for i in range(HOTBAR_SIZE):
         slot_x = ((self.size_x / HOTBAR_SIZE) * i) + self.hotbar_x
         if len(self._hotbar) <= i:
             empty_slot = Rectangle(slot_x,
                                    self.hotbar_y,
                                    PREVIEW_SIZE,
                                    PREVIEW_SIZE, (200, 200, 200),
                                    batch=self._hotbar_batch,
                                    group=self.hud_group)
             empty_slot.opacity = 100
             self._hotbar_sprites.append(empty_slot)
         else:
             self._draw_inventory_slot(slot_x, self.hotbar_y,
                                       self._hotbar[i].get_block_image(),
                                       self._hotbar_batch,
                                       self._hotbar_sprites)