def _display(self): # backgrounds for xc in range(0, self.interface.xcmax + 1): for yc in range(0, self.interface.ycmax + 1): sq = self.interface.server.player.world.grid[(xc, yc)] x, y = xc * self.square_view_width, self.ymax - yc * self.square_view_height if sq in self.interface.server.player.detected_squares: color = (0, 25, 25) elif sq in self.interface.server.player.observed_squares: color = (0, 25, 0) elif sq in self.interface.server.player.observed_before_squares: color = (15, 15, 15) else: color = (0, 0, 0) continue if sq.high_ground: color = (color[0] * 2, color[1] * 2, color[2] * 2) draw_rect(color, x, y - self.square_view_height, self.square_view_width, self.square_view_height, 0) # grid color = (100, 100, 100) for x in range(0, self.interface.xcmax + 2): draw_line(color, (x * self.square_view_width, 0), (x * self.square_view_width, (self.interface.ycmax + 1) * self.square_view_height)) for y in range(0, self.interface.ycmax + 2): draw_line(color, (0, y * self.square_view_height), ((self.interface.xcmax + 1) * self.square_view_width, y * self.square_view_height))
def active_square_view_display(self): xc, yc = self.interface.coords_in_map(self.interface.place) x, y = xc * self.square_view_width, self.ymax - yc * self.square_view_height if self.interface.target is None: color = (255, 255, 255) else: color = (150, 150, 150) draw_rect(color, x, y - self.square_view_height, self.square_view_width, self.square_view_height, 1)
def display(self, grid): xmin, ymin = grid.xy_coords(self.xmin, self.ymin) xmax, ymax = grid.xy_coords(self.xmax, self.ymax) if self.parent.target is None: color = (255, 255, 255) else: color = (150, 150, 150) draw_rect(color, xmin, ymin, xmax - xmin, ymax - ymin, 1)
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": draw_rect(o.corrected_color(), x-R, y-R, R*2, R*2, 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))
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": draw_rect(o.corrected_color(), x - R, y - R, R * 2, R * 2, 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))
def _display(self): # backgrounds for xc in range(0, self.interface.xcmax + 1): for yc in range(0, self.interface.ycmax + 1): sq = self.interface.server.player.world.grid[(xc, yc)] x, y = xc * self.square_view_width, self.ymax - yc * self.square_view_height if sq in self.interface.server.player.detected_squares: color = (0, 25, 25) elif sq in self.interface.server.player.observed_squares: color = (0, 25, 0) elif sq in self.interface.server.player.observed_before_squares: color = (15, 15, 15) else: color = (0, 0, 0) continue if sq.high_ground: color = (color[0]*2, color[1]*2, color[2]*2) draw_rect(color, x, y - self.square_view_height, self.square_view_width, self.square_view_height, 0) # grid color = (100, 100, 100) for x in range(0, self.interface.xcmax + 2): draw_line(color, (x * self.square_view_width, 0), (x * self.square_view_width, (self.interface.ycmax + 1)* self.square_view_height)) for y in range(0, self.interface.ycmax + 2): draw_line(color, (0, y * self.square_view_height), ((self.interface.xcmax + 1) * self.square_view_width, y * self.square_view_height))