예제 #1
0
    def reviewCollection(self, result):
        """Shows unlocked collections, if any.

        :param result: result to look.
        :type result: gameResult.GameResult
        """
        num = len(result.unlockedCollection)
        if num == 0:
            return
        bgtsound.playOneShot(self.sounds["unlock.ogg"])
        self.wait(500)
        s = _("collection") if num == 1 else _("collections")
        m = self.createMenu(
            _("Unlocked %(number)d %(collection)s!") % {
                "number": num,
                "collection": s
            })
        for elem in result.unlockedCollection:
            m.append(str(elem))
        # end for
        m.append(_("Close"))
        m.open()
        while (True):
            self.frameUpdate()
            r = m.frameUpdate()
            if r is None:
                continue
            if r == -1 or m.isLast(r):
                break
            bgtsound.playOneShot(self.sounds["scream%s.ogg" %
                                             m.getString(m.getCursorPos())])
예제 #2
0
    def resultScreen(self, result):
        """Shows the game results screen."""
        m = self.createMenu(_("Game result"))
        m.append(_("Final score: %(score)d") % {"score": result.score})
        if result.highscore is not None:
            m.append(
                _("New high score! Plus %(distance)d (last: %(last)d)") % {
                    "distance": result.highscore - result.previousHighscore,
                    "last": result.previousHighscore
                })
            bgtsound.playOneShot(self.sounds["highscore.ogg"])
            self.statsStorage.set("hs_" + result.mode, result.highscore)
        # end if highscore
        m.append(
            _("Punches: %(punches)d, hits: %(hits)d, accuracy: %(accuracy).2f%%"
              ) % {
                  "punches": result.punches,
                  "hits": result.hits,
                  "accuracy": result.hitPercentage
              })
        for elem in result.getModeSpecificResults():
            m.append(elem)
        # end append mode specific results

        m.append(
            _("This game lasted for %(time)s.") %
            {"time": result.lastedString})
        m.append(_("You reached level %(level)d.") % {"level": result.level})
        m.append(result.log, shortcut=False)
        m.open()
        while (True):
            self.frameUpdate()
            r = m.frameUpdate()
            if r is not None:
                break
예제 #3
0
    def moveTo(self, index):
        """Updates the cursor position.

        :param index: New position.
        :type index: int
        """
        # key hold. Should have reused the menu class one, but I'm lazy.
        if self.lastHold == 1 and self.holdTimer.elapsed < 600:
            return
        if self.lastHold == 2 and self.holdTimer.elapsed < 50:
            return
        self.holdTimer.restart()
        if self.lastHold < 2:
            self.lastHold += 1
        self.index = index
        unlocked = self.appMain.collectionStorage.isUnlocked(index)
        if unlocked:
            bgtsound.playOneShot(self.appMain.sounds["cursor.ogg"])
            s = _("Unlocked")
        else:
            bgtsound.playOneShot(self.appMain.sounds["cursor.ogg"], pitch=80)
            s = _("Locked")
        # end if locked or not
        self.appMain.say(
            _("No.%(no)d, %(status)s, %(plays)d") % {
                "no": index,
                "status": s,
                "plays": self.appMain.collectionStorage.get(index)
            })
예제 #4
0
 def downloadUpdate(self):
     """Sets the download of the new update."""
     if self.updateDownloader and self.updateDownloader.hasSucceeded():
         return
     if self.updateDownloader and self.updateDownloader.isWorking():
         return
     url = buildSettings.UPDATE_PACKAGE_URL[platform.system()]
     local = buildSettings.UPDATE_PACKAGE_LOCAL_NAME[platform.system()]
     if url == "" or local == "":
         self.message(
             _("This build of %(gamename)s doesn't have download location set."
               ) % {"gamename": buildSettings.GAME_NAME})
         return
     # end download location not set
     self.say(
         _("Select the folder where you want to download the installer."))
     fld = self.folderSelect(
         _("Select the folder where you want to download the installer."))
     if not fld:
         return
     bgtsound.playOneShot(self.sounds["confirm.ogg"])
     local = os.path.join(fld, local)
     if os.path.isfile(local):
         if not self.yesno(
                 _("Warning"),
                 local + _(" already exists. Do you want to overwrite?")):
             return
     # end overwriting confirmation
     self.updateDownloader = updateClient.Downloader()
     self.updateDownloader.initialize(url, local, self._downloadComplete)
     self.updateDownloader.run()
예제 #5
0
파일: enemies.py 프로젝트: yncat/tgs19
 def _attack(self):
     bgtsound.playOneShot(globalVars.app.needleSample[random.randint(0, 2)])
     self.world.setPaused(True)
     globalVars.app.wait(700)
     self.world.logAttacked()
     self.world._detatchEnemy(self)
     self.world.setPaused(False)
     self.delete()
예제 #6
0
 def frameUpdate(self):
     """If the time is right, pops a stack and plays an unlock sound."""
     if self.stack == 0:
         return
     if self.timer.elapsed >= UNLOCKED_SOUND_PLAYBACK_INTERVAL:
         self.stack -= 1
         bgtsound.playOneShot(
             globalVars.appMain.sounds[UNLOCKED_SOUND_FILENAME])
         self.timer.restart()
예제 #7
0
    def play(self, index):
        """Plays a scream.

        :param pos: Scream number.
        """
        if self.sound:
            self.sound.stop()
        self.sound = bgtsound.sound()
        self.sound.load(self.appMain.sounds["scream%d.ogg" % index])
        self.sound.pitch = self.pitch
        self.sound.play()
        bgtsound.playOneShot(self.appMain.sounds["confirm.ogg"])
예제 #8
0
    def run(self, appMain):
        """Runs the collection dialog.

        :param wnd: Window on which this dialog runs.
        :type appMain: ssAppMain.SsAppMain
        """
        self.appMain = appMain
        self.sound = None
        appMain.say(
            _("Use your left and right arrows to brows your collections, then press enter to make your unlocked one scream. You can move through your unlocked items with shift + left or right. To play with pitch changing, hold down up and down arrows. Press escape when you're satisfied."
              ))
        self.index = 0
        self.pitch = 100
        self.pitchTimer = window.Timer()
        self.lastHold = 0
        self.holdTimer = window.Timer()

        while (True):
            appMain.frameUpdate()
            if appMain.keyPressed(window.K_ESCAPE):
                break
            if appMain.keyPressing(window.K_LSHIFT) or appMain.keyPressing(
                    window.K_RSHIFT):
                if appMain.keyPressed(window.K_LEFT):
                    self.searchUnlocked(-1)
                if appMain.keyPressed(window.K_RIGHT):
                    self.searchUnlocked(1)
            else:
                left = appMain.keyPressing(window.K_LEFT)
                right = appMain.keyPressing(window.K_RIGHT)
                if not left and not right:
                    self.lastHold = 0
                if left and self.index != 0:
                    self.moveTo(self.index - 1)
                if right and self.index != self.appMain.numScreams - 1:
                    self.moveTo(self.index + 1)
            # end shift or not
            if appMain.keyPressed(window.K_SPACE):
                self.moveTo(self.index)
            if appMain.keyPressed(
                    window.K_RETURN) and appMain.collectionStorage.isUnlocked(
                        self.index):
                self.play(self.index)
            if appMain.keyPressing(
                    window.K_UP
            ) and self.pitchTimer.elapsed >= 50 and self.pitch != enemy.SCREAM_PITCH_HIGH:
                self.changePitch(self.pitch + 1)
            if appMain.keyPressing(
                    window.K_DOWN
            ) and self.pitchTimer.elapsed >= 50 and self.pitch != enemy.SCREAM_PITCH_LOW:
                self.changePitch(self.pitch - 1)
        # end while
        bgtsound.playOneShot(appMain.sounds["confirm.ogg"])
예제 #9
0
    def message(self, msg):
        """
        Shows a simple message dialog. This method is blocking; it won't return until user dismisses the dialog. While this method is blocking, onExit still works as expected.

        :param msg: Message to show.
        :type msg: str
        """
        self.say(msg)
        while (True):
            self.frameUpdate()
            if True in (self.keyPressed(window.K_LEFT),
                        self.keyPressed(window.K_RIGHT),
                        self.keyPressed(window.K_UP),
                        self.keyPressed(window.K_DOWN)):
                self.say(msg)  # Message repeat
            if self.keyPressed(window.K_RETURN):
                break
        # end frame update
        bgtsound.playOneShot(self.sounds["confirm.ogg"])
예제 #10
0
	def play(self):
		self.homeSound.stop()
		self.say("start!")
		w=world.World()
		self.world=w
		while(True):
			self.frameUpdate()
			w.frameUpdate()
			if self.keyPressed(window.K_KP0) or self.keyPressed(window.K_0): self.oscController.recalibrate()
			if w.getGameover(): break
			if self.keyPressed(window.K_ESCAPE) or self.keyPressed(window.K_KP9): break
		#end game loop
		bgtsound.playOneShot(self.gameoverSample,vol=-15)
		w.clear()
		w.terminate()
		self.wait(3000)
		s="ゲームオーバー! あなたは、%d匹の蚊をやっつけて、%d回、蚊に刺されました。" % (w.getScore(), w.getAttacked())
		self.say(s)
		f=open("game_log.txt","a")
		f.write("%s: kill %d, damage %d.\n" % (datetime.datetime.now(),w.getScore(), w.getAttacked()))
		f.close()
예제 #11
0
 def processHighscore(self):
     """Plays the highscore sound and logs that this player has achieved high score."""
     bgtsound.playOneShot(globalVars.appMain.sounds["highscore.ogg"])
     self.gotHighscore = True