Exemplo n.º 1
0
 def display_attack(self, attacker_id, target):
     a = self.interface.dobjets[attacker_id]
     self.interface.grid_view._update_coefs()
     if self.interface.player.is_an_enemy(a):
         color = (255, 0, 0)
     else:
         color = (0, 255, 0)
     pygame.draw.line(get_screen(), color,
                      self.interface.grid_view._object_coords(target),
                      self.interface.grid_view._object_coords(a))
     pygame.draw.circle(get_screen(), (100, 100, 100),
                        self.interface.grid_view._object_coords(target), R*3/2, 0)
     pygame.display.flip() # not very clean but seems to work (persistence of vision?)
Exemplo n.º 2
0
 def display_attack(self, attacker_id, target):
     a = self.interface.dobjets[attacker_id]
     self.interface.grid_view._update_coefs()
     if self.interface.player.is_an_enemy(a):
         color = (255, 0, 0)
     else:
         color = (0, 255, 0)
     pygame.draw.line(get_screen(), color,
                      self.interface.grid_view.object_coords(target),
                      self.interface.grid_view.object_coords(a))
     pygame.draw.circle(get_screen(), (100, 100, 100),
                        self.interface.grid_view.object_coords(target), R*3/2, 0)
     pygame.display.flip() # not very clean but seems to work (persistence of vision?)
Exemplo n.º 3
0
    def display_object(self, o):
        if getattr(o, "is_inside", False):
            return
        if self.interface.target is not None and self.interface.target is o:
            width = 0  # fill circle
        else:
            width = 1
        x, y = self._object_coords(o)
        if o.shape() == "square":
            rect = x - R, y - R, R * 2, R * 2
            draw_rect(o.corrected_color(), rect, width)
        else:
            pygame.draw.circle(get_screen(), o.corrected_color(), (x, y), R,
                               width)
        if getattr(o.model, "player", None) is not None:
            if o.id in self.interface.group:
                color = (0, 255, 0)
            elif o.player is self.interface.player:
                color = (0, 55, 0)
            elif o.player in self.interface.player.allied:
                color = (0, 0, 155)
            elif o.player.is_an_enemy(self.interface.player):
                color = (155, 0, 0)
            else:
                color = (0, 0, 0)
            pygame.draw.circle(get_screen(), color, (x, y), R / 2, 0)
            if getattr(o, "hp", None) is not None and \
               o.hp != o.hp_max:
                hp_prop = 100 * o.hp / o.hp_max
                if hp_prop > 80:
                    color = (0, 255, 0)
##                elif hp_prop > 50:
##                    color = (0, 255, 0)
                else:
                    color = (255, 0, 0)
                W = R - 2
                if color != (0, 255, 0):
                    pygame.draw.line(get_screen(), (0, 55, 0),
                                     (x - W, y - R - 2),
                                     (x - W + 2 * W, y - R - 2))
                pygame.draw.line(get_screen(), color, (x - W, y - R - 2),
                                 (x - W + hp_prop * (2 * W) / 100, y - R - 2))
Exemplo n.º 4
0
    def display_object(self, o):
        if getattr(o, "is_inside", False):
            return
        if self.interface.target is not None and self.interface.target is o:
            width = 0 # fill circle
        else:
            width = 1
        x, y = self._object_coords(o)
        if o.shape() == "square":
            rect = x-R, y-R, R*2, R*2
            draw_rect(o.corrected_color(), rect, width)
        else:
            pygame.draw.circle(get_screen(), o.corrected_color(), (x, y), R, width)
        if getattr(o.model, "player", None) is not None:
            if o.id in self.interface.group:
                color = (0,255,0)
            elif o.player is self.interface.player:
                color = (0,55,0)
            elif o.player in self.interface.player.allied:
                color = (0,0,155)
            elif o.player.player_is_an_enemy(self.interface.player):
                color = (155,0,0)
            else:
                color = (0, 0, 0)
            pygame.draw.circle(get_screen(), color, (x, y), R/2, 0)
            if getattr(o, "hp", None) is not None and \
               o.hp != o.hp_max:
                hp_prop = 100 * o.hp / o.hp_max
                if hp_prop > 80:
                    color = (0, 255, 0)
##                elif hp_prop > 50:
##                    color = (0, 255, 0)
                else:
                    color = (255, 0, 0)
                W = R - 2
                if color != (0, 255, 0):
                    pygame.draw.line(get_screen(), (0, 55, 0),
                                 (x - W, y - R - 2),
                                 (x - W + 2 * W, y - R - 2))
                pygame.draw.line(get_screen(), color,
                                 (x - W, y - R - 2),
                                 (x - W + hp_prop * (2 * W) / 100, y - R - 2))
Exemplo n.º 5
0
 def _collision_display(self):
     for t, c in (("ground", (0, 0, 255)), ("air", (255, 0, 0))):
         for ox, oy in self.interface.collision_debug[t].xy_set():
             pygame.draw.circle(get_screen(), c, self._xy_coords(ox, oy), 0,
                                0)
Exemplo n.º 6
0
 def _update_coefs(self):
     self.square_view_width = self.square_view_height = min(
         (get_screen().get_width() - 200) / (self.interface.xcmax + 1),
         get_screen().get_height() /
         (self.interface.ycmax + 1))  # 200 = graphic console
     self.ymax = self.square_view_height * (self.interface.ycmax + 1)
Exemplo n.º 7
0
 def _collision_display(self):
     for t, c in (("ground", (0, 0, 255)), ("air", (255, 0, 0))):
         for ox, oy in self.interface.collision_debug[t].xy_set():
             pygame.draw.circle(get_screen(), c, self._xy_coords(ox, oy), 0, 0)
Exemplo n.º 8
0
 def _update_coefs(self):
     self.square_view_width = self.square_view_height = min((get_screen().get_width() - 200) / (self.interface.xcmax + 1),
         get_screen().get_height() / (self.interface.ycmax + 1)) # 200 = graphic console
     self.ymax = self.square_view_height * (self.interface.ycmax + 1)