def __init__(self, screen, mapname, pathname): self.screen = screen self.mapimg, self.maprect = load_image(mapname) self.pathimg, self.pathrect = load_image(pathname) self._mode = "map" self._show_range = False screen.blit(self.mapimg, self.maprect) # Find the pixel where the monsters are supposed to come in at for i in range(0, map_HEIGHT): pixel_clr = self.pathimg.get_at((0, i)) if pixel_clr == BLACK: self.entry_point = (-50, i) self.monsters = [] self.towers = []
def __init__(self, screen): pygame.sprite.Sprite.__init__(self) self.img, self.rect = load_image("monster_test.png") self.max_hp = 100 self.hp = self.max_hp self.movspeed = 120 self.movdirection = "right" self.reward = 50 self.screen = screen
def __init__(self, screen, coords): pygame.sprite.Sprite.__init__(self) self.img, self.rect = load_image("tower_test.png") self.rect.center = coords self.shoot_speed = 15 self.damage = 10 self.cost = 100 self.shoot_range = 180 self.next_action = Tower.action_generator(self.shoot_speed) self.screen = screen
def __init__(self, screen, imagepath, max_hp, movspeed, movdirection, reward): """Initializes the monster with its attributes""" pygame.sprite.Sprite.__init__(self) self.img, self.rect = load_image(imagepath, transparent=True) self._hp = max_hp self.hp = self._hp self._movspeed = movspeed self.movspeed = movspeed self.movdirection = "right" self.reward = reward self.effects = [] self.effect_queue = []
def __init__(self, screen, imagepath, coords, cost, shooting_range, shooting_speed, shooting_action, action_modifier, action_target, action_timer): pygame.sprite.Sprite.__init__(self) self.img, self.rect = load_image(imagepath, transparent=True) self._img = self.img self.rect.center = coords self.cost = cost self.shooting_range = shooting_range self.shooting_speed = shooting_speed self.shooting_action = shooting_action self.action_modifier = action_modifier self.action_target = action_target self.action_timer = action_timer self.screen = screen