Ejemplo n.º 1
0
 def move(self):
     self.y += self.V * math_functions.sin(self.x, self.y, Hero.hero.x,
                                           Hero.hero.y) * (1 - self.slow)
     self.x += self.V * math_functions.cos(self.x, self.y, Hero.hero.x,
                                           Hero.hero.y) * (1 - self.slow)
     self.Vx = self.V * math_functions.cos(self.x, self.y, Hero.hero.x,
                                           Hero.hero.y) * (1 - self.slow)
Ejemplo n.º 2
0
    def draw(self):
        if self.type == "mage":
            if self.now_action == "move":
                self.current_animation = draw_images.mage_move
            if self.now_action == "attack":
                self.current_animation = draw_images.mage_attack

        if self.type == "zombie":
            if self.now_action == "move":
                self.current_animation = draw_images.zombie_move
            if self.now_action == "attack":
                self.current_animation = draw_images.zombie_attack

        if self.type == "soldier":
            if self.now_action == "move":
                self.current_animation = draw_images.summon_move
            if self.now_action == "attack":
                self.current_animation = draw_images.summon_attack

        if self.image_index >= len(self.current_animation):
            self.image_index = 0
        self.image = self.current_animation[self.image_index]
        if math_functions.cos(self.x, self.y, Hero.hero.x, Hero.hero.y) < 0:
            self.image = pygame.transform.flip(self.image, True, False)
        Constants.screen.blit(
            self.image,
            (self.x - Hero.my_map.x - 25, self.y - Hero.my_map.y - 25))

        if self.anim_speed >= 3:
            self.anim_speed = 0
        self.anim_speed += 1
        if self.anim_speed == 1:
            self.image_index += 1
Ejemplo n.º 3
0
 def SHOOT(self):
     '''
     стрельба врагов
     b.type=="melee" означает что атака ближнего боя
     пуля подобной атаки не рисуется, но нужна для проверки коллизии
     '''
     if Hero.var.TIME > self.time_to_shoot * Constants.FPS + self.time_last_shoot:
         b = Bullet()
         if self.type == "soldier":
             b.type = "medium"
             b.V = 12
             b.radius = 10
         if self.type == "mage":
             b.type = "fireball"
             b.V = 6
             b.radius = 20
         if self.type == "zombie":
             b.V = 15
             b.type = "melee"
         b.x = self.x
         b.y = self.y
         b.Vy += b.V * math_functions.sin(self.x, self.y, Hero.hero.x,
                                          Hero.hero.y)
         b.Vx += b.V * math_functions.cos(self.x, self.y, Hero.hero.x,
                                          Hero.hero.y)
         Constants.BULLETS.append(b)
         b.radius = 10
         self.time_last_shoot = Hero.var.TIME
Ejemplo n.º 4
0
                    if math_functions.check_wall_collision(Hero.play_button.x,Hero.play_button.y,Hero.play_button.x_size,Hero.play_button.y_size, event.pos[0],event.pos[1],3):
                        draw_images.pygame.mouse.set_visible(False)
                        start_game()

        if var.game_room=="game":

            #       стрельба:
            if event.type == draw_images.pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    Hero.hero.shooting = 1

            if event.type == draw_images.pygame.MOUSEBUTTONUP:
                if event.button == 1:
                    Hero.hero.shooting = 0
            if event.type == draw_images.pygame.MOUSEMOTION:
                var.mouse_projection_x = math_functions.cos(Hero.hero.x, Hero.hero.y, event.pos[0] + Hero.my_map.x,
                                                                 event.pos[1] + Hero.my_map.y)  # var.mouse_proect_x - cos угла между мышкой и героем
                var.mouse_projection_y = math_functions.sin(Hero.hero.x, Hero.hero.y, event.pos[0] + Hero.my_map.x,
                                                                 event.pos[1] + Hero.my_map.y)  # var.mouse_proect_y-sin угла между мышкой и героем
                Hero.aim.x, Hero.aim.y = event.pos[0], event.pos[1]  # кооринаты прицела

                # переключение оружия:
        if event.type == draw_images.pygame.KEYDOWN:
            if event.key == draw_images.pygame.K_BACKSPACE:
                draw_images.pygame.quit()

            if var.game_room=="game":
                if event.key == draw_images.pygame.K_1:
                    if  Hero.hero_weapon2 == Hero.hero_select_weapon:
                        Hero.hero_weapon2 = Hero.hero_select_weapon
                        Hero.hero_select_weapon = Hero.hero_weapon1