Esempio n. 1
0
 def draw_damage(self):
     font = DEJAVUSANS(data.adjust_for_zoom(20))
     if len(data.damage) > 0:
         for dam in data.damage:
             if time.time() - dam.start_time >= 3:
                 del dam
             else:
                 surf = self.scale_image_32(self.DAMAGECIRCLE)
                 surf.set_colorkey(BLACK)
                 rect = surf.get_rect()
                 t_center = rect.center
                 rect.center = dam.defender.square.get_rect().center
                 rect.top -= dam.float
                 text = font.render(str(dam.num),1, WHITE)
                 t_rect = text.get_rect()
                 t_rect.center = t_center
                 surf.blit(text, t_rect)
                 scaled_surf = pygame.transform.smoothscale(surf, (data.unit_size, data.unit_size))
                 scaled_surf.set_alpha(180)
                 self.display.blit(scaled_surf, rect)
                 dam.float += (25 - dam.float) / 20.0
Esempio n. 2
0
 def draw_damage(self):
     font = DEJAVUSANS(data.adjust_for_zoom(20))
     if len(data.damage) > 0:
         for dam in data.damage:
             if time.time() - dam.start_time >= 3:
                 del dam
             else:
                 surf = self.scale_image_32(self.DAMAGECIRCLE)
                 surf.set_colorkey(BLACK)
                 rect = surf.get_rect()
                 t_center = rect.center
                 rect.center = dam.defender.square.get_rect().center
                 rect.top -= dam.float
                 text = font.render(str(dam.num), 1, WHITE)
                 t_rect = text.get_rect()
                 t_rect.center = t_center
                 surf.blit(text, t_rect)
                 scaled_surf = pygame.transform.smoothscale(
                     surf, (data.unit_size, data.unit_size))
                 scaled_surf.set_alpha(180)
                 self.display.blit(scaled_surf, rect)
                 dam.float += (25 - dam.float) / 20.0
Esempio n. 3
0
 def update(self):
     if self.stats['health'] <= 0:
         self.square.unit = None
         unitlist.remove(self)
     elif self.move_dest != None:
         MOVESPEED = data.adjust_for_zoom(2)
         if self.step < data.square_size:
             self.move_offset[0] = self.step * self.move_direction[0]
             self.move_offset[1] = self.step * self.move_direction[1]
             self.step += MOVESPEED
             if self.step >= data.square_size:
 #                print self.name + " moved to " + str(self.move_dest) + " from " + str(self.square) 
                 self.square.unit = None
                 self.square = self.move_dest
                 self.square.unit = self
                 data.selected_square = self.move_dest
                 self.step = 0
                 self.move_dest = None
                 self.move_direction = [0, 0]
                 self.move_offset = [0, 0]
                 self.moving = False
         if len(self.move_route) > 0:
             if self.moving == False:
                 self.move_to_target()