def releasebow(self): self.status[1] = "bow is releasing" self.addanim(8,0,90,3) self.addanim(9,0,-90,3) self.addanim(8,0,92,5) self.addanim(9,0,-92,5) self.addanim(5,0,-130,5) if "arrow" in self.assets: self.assets.remove("arrow") arr = projectile.Arrow(self.x+self.calcCoord(5)[0]*self.s*self.dir,self.yo+self.y+self.calcCoord(5)[1]*self.s) arr.a = self.calcCoord(10)[2] #print(arr.a) arr.l = 25*self.s arr.spd = 1+0.05*max(1,self.skel[1][0]-100)*max(1,self.skel[8][0]-90) arr.v = arr.calcV() arr.color = self.color self.arrows.append(arr) def f(x): self.addanim(8,1,0,20) self.addanim(9,1,0,20) self.animback(20,exceptions=[3,8,9]) self.status[1] = "" def g(x): self.assets.remove("bow") self.timers.append([25,g,[0],"removebow"]) self.timers.append([25,f,[0],"releasebow"])
def action(self, monsters): if self.type is None: return None if self.reload > 0: self.reload -= 1 self.bar_indicator.set_value(self.reload_time - self.reload, self.reload_time) return None best, target = float("inf"), None src = self.rect.center for monster in monsters: dist = utils.distance(src, monster.rect.center) if dist < best: best, target = dist, monster if target is not None and best <= self.radius: if self.type == 0 or self.type == 1: p = projectile.Arrow(self.position, target, self.damage) elif self.type == 2: p = projectile.FireBall(self.position, target, self.damage) else: # self.type == 3 p = projectile.IceBall(self.position, target, self.damage) self.reload = self.reload_time return p return None
def shoot(self, target_sprite): self.view_position = self.position arrow = projectile.Arrow() arrow.max_range = random.randint(int(arrow.max_range * 0.667), arrow.max_range) arrow.min_range = arrow.max_range return arrow.shoot(self, target_sprite.center_x, target_sprite.center_y)
def on_mouse_press(self, x, y, button, modifiers): if button == arcade.MOUSE_BUTTON_LEFT: if len(self.melee_list) == 0: sword = melee.Sword() self.melee_list.append(sword.attack(self.player,self._mouse_x, self._mouse_y)) elif button == arcade.MOUSE_BUTTON_RIGHT: if self.player.ammo > 0: arrow = projectile.Arrow() self.charge_list.append(arrow)
def drop(self): '''Creates arrows to drop''' try: drop = self.drop_list[random.randint(0, 20)] # drop = self.drop_list[1] except IndexError: drop = 0 drop_list = [] for each in range(drop): arrow = projectile.Arrow(position=self.position) drop_list.append(arrow) return drop_list
def on_mouse_press(self, x, y, button, modifiers): # def on_mouse_scroll(self, x, y, button, modifiers): # def on_mouse_motion(self, x, y, button, modifiers): if button == arcade.MOUSE_BUTTON_LEFT: if len(self.melee_list) == 0: sword = melee.Sword() # if modifiers == arcade.key.MOD_SHIFT: # self.projectile_list.append(sword.throw(self.player_sprite,self._mouse_x,self._mouse_y)) # else: self.melee_list.append( sword.attack(self.player_sprite, self._mouse_x, self._mouse_y)) elif button == arcade.MOUSE_BUTTON_RIGHT: if self.ammo > 0: arrow = projectile.Arrow() self.charge_list.append(arrow)