Пример #1
0
    def __init__(self, scene, x=0, y=0, lives=2):
        super().__init__(scene, x, y)
        self.lives = lives
        self.i = 0
        """add Bomberman + 被炸flash"""
        self.animations.add("down",
                            glob.glob("Sprites/Bomberman/Front/*"),
                            interval=50)
        self.animations.add("up",
                            glob.glob("Sprites/Bomberman/Back/*"),
                            interval=50)
        self.animations.add("right",
                            glob.glob("Sprites/Bomberman/Side/*"),
                            interval=50)
        self.animations.add("left",
                            glob.glob("Sprites/Bomberman/Side/*"),
                            interval=50,
                            horizontal_flip=True)
        self.animations.add(
            "flash", [glob.glob("Sprites/Bomberman/Front/*")[0], None] * 4,
            interval=200)

        self.set_default_image("down")
        self.speed = 8  # how many pixels to move per frame
        # only the lower part (defined by collision_rect) of Bomberman can collide with other sprites
        self.collision_rect = QtCore.QRect(10,
                                           self.image.height() // 3 * 2,
                                           self.image.width() - 20,
                                           self.image.height() // 3)
        self.setZValue(9999)  # bomberman is always on top of other sprites
        self.explosion_sound = QSound("bgm.wav")
        self.explosion_sound.play()

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.count_down)
        self.timer.start(70000)

        self.destroy_timer = QtCore.QTimer()
        self.destroy_timer.timeout.connect(self.destroy)
Пример #2
0
    def __init__(self, scene, x=0, y=0):
        super().__init__(scene, x, y)
        elves = self.animations.extract_images("Sprites/Elves/grass.png",
                                               n_rows=4,
                                               n_columns=4)
        self.animations.add("down", elves[0:4], interval=100)
        self.animations.add("left", elves[4:8], interval=100)
        self.animations.add("right", elves[8:12], interval=100)
        self.animations.add("up", elves[12:16], interval=100)
        self.animations.add("flash", [elves[0], None] * 4, interval=200)
        self.set_default_image("up")
        self.speed = 6  # how many pixels to move per frame
        # only the lower part (defined by collision_rect) of Bomberman can collide with other sprites
        self.collision_rect = QtCore.QRect(10,
                                           self.image.height() // 3 * 2,
                                           self.image.width() - 20,
                                           self.image.height() // 3)
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.grasss_win)
        self.timer.start(76000)

        self.move_timer = QtCore.QTimer()
        self.move_timer.timeout.connect(self.move_randomly)
Пример #3
0
    def __init__(self, scene, x=0, y=0):
        super().__init__(scene, x, y)
        # self.i = 0
        """add Creep + 被炸flash"""
        self.animations.add("down",
                            glob.glob("Sprites/Creep/Front/*"),
                            interval=50)
        self.animations.add("up",
                            glob.glob("Sprites/Creep/Back/*"),
                            interval=50)
        self.animations.add("right",
                            glob.glob("Sprites/Creep/Side/*"),
                            interval=50)
        self.animations.add("left",
                            glob.glob("Sprites/Creep/Side/*"),
                            interval=50,
                            horizontal_flip=True)
        self.animations.add("flash",
                            [glob.glob("Sprites/Creep/Front/*")[0], None] * 4,
                            interval=200)
        self.animations.add("win", glob.glob("Sprites/Creep/Happy/*"))

        self.set_default_image("down")
        self.speed = 4  # how many pixels to move per frame
        # only the lower part (defined by collision_rect) of Bomberman can collide with other sprites
        self.collision_rect = QtCore.QRect(10,
                                           self.image.height() // 3 * 2,
                                           self.image.width() - 20,
                                           self.image.height() // 3)
        self.setZValue(9998)  # bomberman is always on top of other sprites

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.creep_win)
        self.timer.start(76000)

        self.move_timer = QtCore.QTimer()
        self.move_timer.timeout.connect(self.move_randomly)
Пример #4
0
    def __init__(self, scene, x=0, y=0):
        super().__init__(scene, x, y)
        self.animations.add("down", glob.glob("Sprites/Bomberman/Front/*"), interval=25)
        self.animations.add("up", glob.glob("Sprites/Bomberman/Back/*"), interval=25)
        self.animations.add("right", glob.glob("Sprites/Bomberman/Side/*"), interval=25)
        self.animations.add("left", glob.glob("Sprites/Bomberman/Side/*"), interval=25, horizontal_flip=True)
        self.animations.add("flash", [glob.glob("Sprites/Bomberman/Front/*")[0], None] * 4, interval=100)
        self.set_default_image("down")
        self.collision_rect = QtCore.QRect(10, self.image.height() // 3 * 2, self.image.width() - 20, self.image.height() // 3)
        self.setZValue(9998)  # bomberman is always on top of other sprites

        #properties
        self.speed = 8  # how many pixels to move per frame
        self.timer = QtCore.QTimer()  #set a timer to avoid contiuously placing bomb
        self.timer.timeout.connect(self.updateTimer)
        self.startTimer()
Пример #5
0
 def __init__(self):
     self.i = 175
     self.timer = QtCore.QTimer()
     self.timer.timeout.connect(self.update)
     self.timer.start(2300)