Пример #1
0
    def shot(self, pos, velocity):
        if self.time >= self.reload_time:
            AudioManager.instance().play_sound(SoundName.Sound5)
            x = velocity[0]
            y = velocity[1]
            velocity[0] = self._rotated[0] * x + self._rotated[1] * y
            velocity[1] = -self._rotated[1] * x + self._rotated[0] * y
            if isinstance(self.color, str):
                c = pygame.color.THECOLORS[self.color]
            else:
                c = self.color

            if self.bulType == 0:
                bullets = BulletManager.instance().get_bullet(3)
            if self.bulType == 1:
                bullets = BulletManager.instance().get_expBullet(3)
            for b in bullets:
                b.shape.collision_type = self.collision
                b.color = c
                b.body.position = pos
                b.body.velocity = velocity

                x = velocity[0]
                y = velocity[1]
                velocity[0] = self._rotated[0] * x - self._rotated[1] * y
                velocity[1] = self._rotated[1] * x + self._rotated[0] * y
            self.time = 0
Пример #2
0
    def shot(self, pos, velocity):
        """
        :param pos: позиция
        :param velocity: скорость: число module
        :return:
        """
        radius = self._radius
        AudioManager.instance().play_sound(SoundName.Sound4)

        n = self._n
        dx = self._dx
        dy = self._dy

        force = velocity[0] / radius

        xx = radius
        yy = 0
        bullets = BulletManager.instance().get_bullet(n)
        for b in bullets:
            b.shape.collision_type = self._collision
            b.color = self.color
            b.body.position = (pos[0] + xx, pos[1] + yy)
            b.body.velocity = (xx * force, yy * force)
            x = xx
            xx = x * dx + yy * dy
            yy = -x * dy + yy * dx
Пример #3
0
 def toggle_music_down(self):
     volume = FileManager.instance().get(FileName.Setting, "music_volume")
     if volume > 0:
         volume -= 0.01
     volume = int(100 * volume) / 100
     self._buttons[0].text = 'Громкость музыки:{0}'.format(volume)
     FileManager.instance().set(FileName.Setting, 'music_volume', volume)
     Core.instance().update_settings()
     UIManager.instance().set_screen(VolumeMode())
     AudioManager.instance().set_volume()
Пример #4
0
 def toggle_up(self):
     volume = FileManager.instance().get(FileName.Setting, "volume")
     if volume < 1:
         volume += 0.01
     volume = int(100 * volume) / 100
     if volume == 0.06:
         volume = 0.07
     if volume == 0.57:
         volume = 0.58
     self._buttons[0].text = 'Громкость эффектов:{0}'.format(volume)
     FileManager.instance().set(FileName.Setting, 'volume', volume)
     Core.instance().update_settings()
     UIManager.instance().set_screen(VolumeMode())
     AudioManager.instance().set_volume()
Пример #5
0
    def update(self, delta: float):
        if self._zoom > 0 and self._camera.zoom < self._camera.max_zoom:
            self._camera.zoom += 0.01
        elif self._zoom < 0 and self._camera.zoom > self._camera.min_zoom:
            self._camera.zoom -= 0.01

        self._player.move(self._direction)
        self._world.step(delta)
        self._camera.pos = self._player.body.position

        if self._player.life <= 0:
            AudioManager.instance().play_sound(SoundName.Sound7)
            UIManager.instance().set_screen(MenuMode())
        self._playerUI.update()
Пример #6
0
    def shot(self, pos, velocity):
        if self.time >= self.reload_time:
            b = None
            if self.bulType == 0:
                b = BulletManager.instance().get_bullet()
            if self.bulType == 1:
                b = BulletManager.instance().get_expBullet()
            AudioManager.instance().play_sound(SoundName.Sound6)

            b.shape.collision_type = self.collision
            if isinstance(self.color, str):
                c = pygame.color.THECOLORS[self.color]
            else:
                c = self.color
            b.color = c
            b.body.position = pos
            b.body.velocity = velocity
            self.time = 0
Пример #7
0
 def __init__(self):
     # pygame.mixer.music.set_volume(1)
     AudioManager.instance().set_music('resources/sounds/Menu.mp3')
     self._screen_h = Core.instance().info().current_h
     self._screen_w = Core.instance().info().current_w
     self._buttons = [
         Button(
             int(self._screen_w / 3), int(self._screen_h / 8),
             int(self._screen_w / 3), int(self._screen_h / 8), 'Новая игра',
             lambda: UIManager.instance().set_screen(
                 (lambda: DebugMode() if FileManager.instance().get(
                     FileName.Setting, 'debug') else GameMode())())),
         Button(int(self._screen_w / 3),
                int(self._screen_h / 4) + int(self._screen_h / 8 * 0.29),
                int(self._screen_w / 3), int(self._screen_h / 8),
                'Настройки',
                lambda: UIManager.instance().set_screen(SettingsMode()))
     ]
Пример #8
0
    def __init__(self):
        AudioManager.instance().set_music(
            'resources/sounds/peacefullmusic.mp3')
        self._level = FileName.Level_0
        self._world = World()
        self._factory = DemoFactory(self._world, self._level)
        self._player = self._factory.create_player()
        GameManager.instance().create(self._world, self._player)
        self._factory.create()

        self._screen_h = pygame.display.Info().current_h
        self._render = WorldRender()
        self._camera = Camera(Core.instance().info().current_w, self._screen_h)
        self._render.set_camera(self._camera)
        self._direction = 0
        self._zoom = 0
        # test PlayerUI
        self._playerUI = PlayerUI(self._player)
Пример #9
0
    def shot(self, pos, velocity):
        """
        :param pos: позиция
        :param velocity: скорость: число module
        """
        if self.time > self.reload_time:
            AudioManager.instance().play_sound(SoundName.Sound4)

            n = self._n
            dx = self._dx
            dy = self._dy

            xx = velocity[0]
            yy = velocity[1]
            bullets = BulletManager.instance().get_bullet(n)
            for b in bullets:
                b.shape.collision_type = self._collision
                b.color = self.color
                b.body.position = (pos[0], pos[1])
                b.body.velocity = (xx, yy)
                x = xx
                xx = x * dx + yy * dy
                yy = -x * dy + yy * dx
            return True
Пример #10
0
 def clicked(self, *arg):
     AudioManager.instance().play_sound(SoundName.Sound4)
     if len(arg) != 0:
         self._click(arg[0])
     else:
         self._click()