Exemple #1
0
    def cmd_exit(self):
        """ Safely close program. """
        import main_game

        affirm = raw_input("Do you want to exit? (y/n)\n")
        if affirm == "n":
            return
        elif affirm == "y":
            choice = raw_input("Would you like to save before exiting? (y/n)\n")
            if choice == "y":
                self.cmd_save()
                self.screen.clear()
                main_game.high_scores(self)
                again = raw_input("Play again? (y/n)\n")
                if again == "y":
                    main_game.main()
                else:
                    print ("Closing game...")
                    sleep(1)
                    self.screen.clear()
                    sys.exit()
            else:
                self.screen.clear()
                main_game.high_scores(self)
                again = raw_input("Play again? (y/n)\n")
                if again == "y":
                    main_game.main()
                else:
                    print ("Closing game...")
                    sleep(1)
                    self.screen.clear()
                    sys.exit()
Exemple #2
0
    def room_change(self, item):
        # sound.set_volume(.10)
        self.room = self.exit_links[item.attrs["type"]]
        self.state.player[0].room[0].attrs["name"] = self.room.attrs["name"]

        if self.room.attrs["name"] != "living room":
            pygame.mixer.init()
            sound = pygame.mixer.Sound("Sounds/Galaga_ChallengeComp.wav")
            sound.set_volume(0.10)
            sound.play()
            self.screen.cprint(3, 0, "")
            print "\n" + " " * 50 + self.room.attrs["name"].upper()
            self.screen.cprint(15, 0, "")
            print self.room.desc[0].value
        else:
            self.screen.cprint(3, 0, "")
            print "\n" + " " * 50 + self.room.attrs["name"].upper()
            self.screen.cprint(15, 0, "")
            print self.room.desc[0].value
            # self.sound.mixer.fadeout(500)
            cont = raw_input("\n\nPress any key to continue.")
            if cont or cont == "":
                import main_game

                self.sound.fadeout(500)
                self.screen.clear()
                main_game.high_scores(self)
                again = raw_input("Play again? (y/n)\n")
                if again == "y":
                    main_game.main()
                else:
                    print ("Closing game...")
                    sleep(1)
                    self.screen.clear()
                    sys.exit()