Exemplo n.º 1
0
    def notifyCollide(self, collider):
        if collider is None:
            return

        if collider.type == "hero":
            play_sound('assets/music/effects/exploded.wav')
            self.parent.resetGame()
Exemplo n.º 2
0
    def spawn(self, parent):
        if self.canSpawn:
            # Spawning based on world height and Car height
            spawnLimit = int((parent.height / self.spawnFrequency) + (parent.hero.height * self.padding))

            # Check if should spawn
            if self.latestSpawnTime > spawnLimit:

                dice = PercentChance(10)
                print("Radar chance: ")
                spawnradar = dice.roll()
                if spawnradar and not self.lastWasRadar:
                    self.canSpawn = False
                    self.spawnRadar(parent)
                else:
                    print("Speed chance: ")
                    cardice = PercentChance(25)
                    shouldDoubleSpeed = cardice.roll()
                    if shouldDoubleSpeed and not self.lastWasRadar and not self.lastWasDouble and not self.lastWasMiddle:
                        play_sound('assets/music/effects/fast.wav')
                        # effect = pygame.mixer.Sound('assets/music/effects/fast.wav')
                        # effect.play()
                        self.spawnCar(parent, 2)
                    else:
                        print("Spawning normal car")
                        self.spawnCar(parent, 1)

            if parent.shouldFall:
                self.latestSpawnTime += parent.dropHeight
Exemplo n.º 3
0
    def spawn(self, parent):
        if self.canSpawn:
            # Spawning based on world height and Car height
            spawnLimit = int((parent.height / self.spawnFrequency) +
                             (parent.hero.height * self.padding))

            # Check if should spawn
            if self.latestSpawnTime > spawnLimit:

                dice = PercentChance(10)
                print("Radar chance: ")
                spawnradar = dice.roll()
                if spawnradar and not self.lastWasRadar:
                    self.canSpawn = False
                    self.spawnRadar(parent)
                else:
                    print("Speed chance: ")
                    cardice = PercentChance(25)
                    shouldDoubleSpeed = cardice.roll()
                    if shouldDoubleSpeed and not self.lastWasRadar and not self.lastWasDouble and not self.lastWasMiddle:
                        play_sound('assets/music/effects/fast.wav')
                        # effect = pygame.mixer.Sound('assets/music/effects/fast.wav')
                        # effect.play()
                        self.spawnCar(parent, 2)
                    else:
                        print("Spawning normal car")
                        self.spawnCar(parent, 1)

            if parent.shouldFall:
                self.latestSpawnTime += parent.dropHeight
Exemplo n.º 4
0
 def handleEvent(self, inputResult):
     if not self.canMove:
         if inputResult == GameDefine.COMMAND_LEFT or inputResult == GameDefine.COMMAND_RIGHT:
             play_sound('assets/music/effects/gotcha.wav')
             self.parent.resetGame()