def __init__(self, position, turret_type, player): pygame.sprite.Sprite.__init__(self, self.groups) self.current_angle = 0 self.turret_type = turret_type self.stats = turret_stats(turret_type, 'basic_stats') self.orginal_image = self.stats[0] self.image = self.orginal_image # holds rotated image self.rotatable = self.stats[1] # can the tower be rotated? self.range = self.stats[2] # range in pixels self.SHOOTING_TIMER = self.stats[3] # time between shots self.cost = self.stats[4] self.targeting_type = self.stats[5] # useful for targeting self.bullet_limit = self.stats[6] self.shoots_at_front = self.stats[6] self.rect = self.image.get_rect() # get it, just get it grid_position = snap_to_grid(position) self.rect.center = (grid_position) # where shall i go dear slavelord self.shooting_timer = 0 # start at 0 so we are loaded when tower is placed player.money -= self.cost # were you expecting a free high tech weapon? self.current_target = 0 # the target is the one FIX THIS self.target = None # actual target self.shots = []
def __init__(self, position, tower_type): self.groups = towers, all_update, all_draw, all_objects # same as above pygame.sprite.Sprite.__init__(self, self.groups) self.current_angle = 0 self.tower_type = tower_type self.stats = Tower_Stats(tower_type) self.orginal_image = self.stats["image"] self.image = self.orginal_image # holds rotated im age self.rotatable = self.stats["rotatable"] # can the tower be rotated? self.range = self.stats["radius"] # range in pixels self.speed = self.stats["speed"] # time between shots self.targeting_type = self.stats["targeting"] # useful for targeting self.bullet_limit = self.stats["bullet_limit"] self.shoots_at_front = self.stats["shoots_at_front"] self.damage = self.stats["bullet_damage"] self.rect = self.image.get_rect() # get it, just get it self.upgrade_counter = 0 grid_position = snap_to_grid(position) self.rect.center = grid_position # where shall i go dear slavelord self.shooting_timer = 0 # start at 0 so we are loaded when tower is placed self.current_target = 0 # the target is the one FIX THIS self.target = None # actual target self.shots = []
def __init__(self, position, turret_type) : # gets location and the kind of tower pygame.sprite.Sprite.__init__(self, self.groups) self.turret_type = turret_type self.image = turret_stats(turret_type, 'image') # get the image self.image.set_alpha(175) # make the image see through 255 is most visible self.rect = self.image.get_rect() grid_position = snap_to_grid(position) # put the position in the grid form self.rect.center = (grid_position) self.radius = turret_stats(turret_type, 'radius') # get the radius of the turret
def __init__(self, position): self.groups = tower_upgrader, all_draw, all_objects pygame.sprite.Sprite.__init__(self, self.groups) self.image = pygame.image.load( os.path.join("Resources", "Images", "Sprites", "Towers", "upgrade.png") ).convert_alpha() self.image.set_alpha(175) self.rect = self.image.get_rect() grid_position = snap_to_grid(position) # put the position in the grid form self.rect.center = grid_position self.radius = 100
def __init__(self, position, tower_type): # gets location and the kind of tower self.groups = towerplacers, all_draw, all_objects pygame.sprite.Sprite.__init__(self, self.groups) self.tower_type = tower_type self.image = Tower_Stats(tower_type)["image"] # get the image self.image.set_alpha(175) # make the image see through 255 is most visible self.rect = self.image.get_rect() grid_position = snap_to_grid(position) # put the position in the grid form self.rect.center = grid_position self.radius = Tower_Stats(tower_type)["radius"] # get the radius of the tower
def __init__(self, position): self.groups = manual_shot_group, all_draw, all_objects pygame.sprite.Sprite.__init__(self, self.groups) self.stats = Tower_Stats(MANUAL_SHOT) self.image = self.stats["image"] self.image.set_alpha(175) # make the image see through 255 is most visible self.rect = self.image.get_rect() grid_position = snap_to_grid(position) # put the position in the grid form self.rect.center = grid_position self.radius = self.stats["radius"] # get the radius of the tower self.damage = self.stats["bullet_damage"]
def move(self, position): grid_position = snap_to_grid(position) self.rect.center = grid_position
def move(self, position): p = snap_to_grid(position) self.rect.center = min(p[0], 825), min(p[1], 575)
def __init__(self, position, turret_type, player): pygame.sprite.Sprite.__init__(self, self.groups) self.current_angle = 0 self.turret_type = turret_type self.stats = turret_stats(turret_type, "basic_stats") self.orginal_image = self.stats[0] self.image = self.orginal_image # holds rotated image self.rotatable = self.stats[1] # can the tower be rotated? self.range = self.stats[2] # range in pixels self.SHOOTING_TIMER = self.stats[3] # time between shots self.cost = self.stats[4] self.targeting_type = self.stats[5] # useful for targeting self.bullet_limit = self.stats[6] self.shoots_at_front = self.stats[6] """ self.image1 = pygame.image.load("Images/Towers/new towers/basic gun1.png").convert() self.image2 = pygame.image.load("Images/Towers/new towers/basic gun2.png").convert() self.image3 = pygame.image.load("Images/Towers/new towers/basic gun3.png").convert() self.image4 = pygame.image.load("Images/Towers/new towers/basic gun4.png").convert() self.image5 = pygame.image.load("Images/Towers/new towers/basic gun5.png").convert() self.image6 = pygame.image.load("Images/Towers/new towers/basic gun6.png").convert() self.image7 = pygame.image.load("Images/Towers/new towers/basic gun7.png").convert() self.image8 = pygame.image.load("Images/Towers/new towers/basic gun8.png").convert() self.image9 = pygame.transform.rotate(self.image1, 90) self.image10 = pygame.transform.rotate(self.image2, 90) self.image11 = pygame.transform.rotate(self.image3, 90) self.image12 = pygame.transform.rotate(self.image4, 90) self.image13 = pygame.transform.rotate(self.image5, 90) self.image14 = pygame.transform.rotate(self.image6, 90) self.image15 = pygame.transform.rotate(self.image7, 90) self.image16 = pygame.transform.rotate(self.image8, 90) self.image17 = pygame.transform.rotate(self.image1, 180) self.image18 = pygame.transform.rotate(self.image2, 180) self.image19 = pygame.transform.rotate(self.image3, 180) self.image20 = pygame.transform.rotate(self.image4, 180) self.image21 = pygame.transform.rotate(self.image5, 180) self.image22 = pygame.transform.rotate(self.image6, 180) self.image23 = pygame.transform.rotate(self.image7, 180) self.image24 = pygame.transform.rotate(self.image8, 180) self.image25 = pygame.transform.rotate(self.image1, 270) self.image26 = pygame.transform.rotate(self.image2, 270) self.image27 = pygame.transform.rotate(self.image3, 270) self.image28 = pygame.transform.rotate(self.image4, 270) self.image29 = pygame.transform.rotate(self.image5, 270) self.image30 = pygame.transform.rotate(self.image6, 270) self.image31 = pygame.transform.rotate(self.image7, 270) self.image32 = pygame.transform.rotate(self.image8, 270) """ self.rect = self.image.get_rect() # get it, just get it grid_position = snap_to_grid(position) self.rect.center = grid_position # where shall i go dear slavelord self.shooting_timer = 0 # start at 0 so we are loaded when tower is placed player.money -= self.cost # were you expecting a free high tech weapon? self.current_target = 0 # the target is the one FIX THIS self.target = None # actual target self.shots = []