コード例 #1
0
    def __init__(self, root):
        '''
        **This is currently just test code that makes it easier to view only the 
        windows relevant for editing/testing at any given time
        '''
        self.main_menu = root
        self.main_menu.title("Vocab GrabBag")
        self.main_menu.minsize(
            width="256", height="144"
        )  #a minimum 16:9 aspect ratio I chose based on personal preference

        #Passing the toplevel window from here to children GUI classes necessitates using a lambda
        self.convert_button = ttk.Button(
            self.main_menu,
            text="Add a Deck",
            command=lambda: MainMenu.open_converter_window(self.main_menu))
        self.convert_button.pack()

        self.play_button = ttk.Button(
            self.main_menu,
            text="Play Vocab GrabBag",
            command=lambda: MainMenu.open_game_window(self.main_menu))
        self.play_button.pack()

        self.test_button = ttk.Button(
            self.main_menu,
            text="Test Window",
            command=lambda: MainMenu.open_test_window(self.main_menu))
        self.test_button.pack()
コード例 #2
0
ファイル: Main.py プロジェクト: Inderpreet-D/CPSC231-Reversi
def main():
    #Set up the other classes
    MainMenu.main()
    ReversiGrid.main()

    #Generate a random board
    #token = BoardGenerator.generate(False, False)

    #Use a blank starting board
    token = Constants.PIECE_NONE * Constants.NUM_OF_CELLS

    #Place the pieces from the random board
    StringInterpret.stringToPiece(token, 0)

    #Place starting config
    token = StringInterpret.stringInterpret(token, "D4", 0)
    token = StringInterpret.stringInterpret(token, "E4", 1)
    token = StringInterpret.stringInterpret(token, "E5", 2)
    token = StringInterpret.stringInterpret(token, "D5", 3)
    move_num = 4

    #Determine who goes first
    rand_num = random.randint(0, 1)
    isPlayerMove = rand_num == 0

    #Start listening for clicks on a board,
    #BoardClick takes over the logic from here
    BoardClick.run(token, move_num, isPlayerMove)
コード例 #3
0
 def test_changeState(self):
     for i in range(len(stateChanges)):
         testObj = MainMenu()
         prevState = testObj.state
         testObj.changeState(stateChanges[i])
         if i > 3: self.assertEquals(testObj.state, prevState)
         else: self.assertEquals(testObj.state, stateChanges[i])
コード例 #4
0
 def test_changeState(self) :
     for i in range(len(stateChanges)) :
         testObj = MainMenu()
         prevState = testObj.state
         testObj.changeState(stateChanges[i])
         if i>3 : self.assertEquals(testObj.state,prevState) 
         else : self.assertEquals(testObj.state, stateChanges[i])
コード例 #5
0
ファイル: Main.py プロジェクト: Barbatos/BumpNJump
	def __init__(self):
		screenWidth = 1000
		screenHeight = 600

		pygame.init()
		if(Resources.getOptionValue("fullscreen") == 1):
			pygame.display.set_mode((screenWidth, screenHeight), FULLSCREEN)
		else:
			pygame.display.set_mode((screenWidth, screenHeight))
		pygame.display.set_caption("Bump'N'Jump")

		pygame.mixer.music.load("resources/sound/music.wav")
		pygame.mixer.music.set_volume(float(Resources.getOptionValue("music"))/100)
		pygame.mixer.music.play(-1)

		currentScene = MainMenu()

		clock = pygame.time.Clock()

		game = True

		while game:
			game, currentScene = currentScene.update()

			clock.tick(60)
コード例 #6
0
 def __init__(self):
     self.largestMagnitude = 0;
     self.currentMagnitude = 0;
     self.width = 625
     self.height = 500
     self.centerX = (self.width - 125) / 2
     self.centerY = self.height / 2
     self.fieldList = []
     self.particleList = []
     self.grid = True
     self.fieldLines = True
     self.fieldDensity = True
     self.cMenu = "start"
     self.rMenu = "mainMenu"
     self.root = tk.Tk()
     self.root.geometry(str(self.width) + "x" + str(self.height))
     self.root.resizable(False, False)
     self.mainMenu = MainMenu(self)
     self.addParticle = AddParticle(self)
     self.measure = Measure(self)
     self.addField = AddField(self)
     self.option = Option(self)
     self.stage = Stage(self)
     self.root.after(1, self.loop)
     self.root.mainloop()
コード例 #7
0
def blitTextMain1():
    
    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 0 else False,
                'Singleplayer',resolution),(resolution[0]/3,resolution[1]/4))
    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 1 else False,
                'Multiplayer',resolution),(resolution[0]/3,resolution[1]/2))
    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 2 else False,
                'Options',resolution),(resolution[0]/3,3*resolution[1]/4))
    return
コード例 #8
0
def blitResolutionOptions():

    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 0 else False,
                '720x480',resolution),(resolution[0]/3,resolution[1]/4))
    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 1 else False,
                    '1280x720',resolution),(resolution[0]/3,resolution[1]/2))
    screen.blit(MainMenu.mainMenuText(True if (cursorMain % 3) == 2 else False,
                '1366x768',resolution),(resolution[0]/3,3*resolution[1]/4))
    return
コード例 #9
0
ファイル: Graphics.py プロジェクト: awh216/nextGenPOS
class Graphics(Frame):
	def __init__(self,parent):
		Frame.__init__(self,parent)
		self.POS = POS().instance
		self.parent = parent

		
		self.mainMenu = MainMenu(parent,self)
		self.loginWindow = LoginWindow(parent,self)
		self.transactionWindow = TransactionWindow(parent,self)
		self.manageUsers = ManageUsersWindow(parent,self)
		self.paymentWindow = PaymentWindow(parent,self)
		self.returnWindow = ReturnWindow(parent,self)
		self.rentalPaymentWindow = RentalPaymentWindow(parent,self)

		container = Frame(self)
		container.pack(side="top", fill="both", expand=True)

		self.mainMenu.place(x=0,y=0,relwidth=1,relheight=1)
		self.loginWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.transactionWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.manageUsers.place(x=0,y=0,relwidth=1,relheight=1)
		self.paymentWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.returnWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.rentalPaymentWindow.place(x=0,y=0,relwidth=1,relheight=1)

		self.loginWindow.lift()

		self.initUI()

	def initUI(self):

		self.parent.title("NextGen POS")

		#can do menubar stuff here if we want

	def onExit(self):
		self.quit()

	def liftLayer(self,layer):
		if layer == "main":
			self.mainMenu.lift()
		elif layer == "login":
			self.loginWindow.lift()
			#add something here to logout as the current user
		elif layer == "transaction":
			self.transactionWindow.lift()
		elif layer == "manageUsers":
			self.manageUsers.lift()
		elif layer == "payment":
			self.paymentWindow.lift()
		elif layer == "return":
			self.returnWindow.lift()
		elif layer == "Rpayment":
			self.rentalPaymentWindow.lift()
コード例 #10
0
 def __init__(self, width, height):
     """ Initializes the game application
     """
     pygame.init()
     pygame.display.set_caption("SDKuPG")
     self._rect = pygame.Rect(0, 0, width, height)
     self._screen = pygame.display.set_mode(self._rect.size)
     self._game_screen = GameScreen(self._screen)
     self._main_menu = MainMenu(self._screen)
     self._menus = {}
     lst = ["on_game_screen", "on_game_screen"]
     for menu in lst:
         self._menus[menu] = False
     self._menus["on_main_menu"] = True
コード例 #11
0
ファイル: Graphics.py プロジェクト: awh216/nextGenPOS
	def __init__(self,parent):
		Frame.__init__(self,parent)
		self.POS = POS().instance
		self.parent = parent

		
		self.mainMenu = MainMenu(parent,self)
		self.loginWindow = LoginWindow(parent,self)
		self.transactionWindow = TransactionWindow(parent,self)
		self.manageUsers = ManageUsersWindow(parent,self)
		self.paymentWindow = PaymentWindow(parent,self)
		self.returnWindow = ReturnWindow(parent,self)
		self.rentalPaymentWindow = RentalPaymentWindow(parent,self)

		container = Frame(self)
		container.pack(side="top", fill="both", expand=True)

		self.mainMenu.place(x=0,y=0,relwidth=1,relheight=1)
		self.loginWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.transactionWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.manageUsers.place(x=0,y=0,relwidth=1,relheight=1)
		self.paymentWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.returnWindow.place(x=0,y=0,relwidth=1,relheight=1)
		self.rentalPaymentWindow.place(x=0,y=0,relwidth=1,relheight=1)

		self.loginWindow.lift()

		self.initUI()
コード例 #12
0
ファイル: main.py プロジェクト: matr095/SaintLaurent
class Main:

    pygame.init()

    fenetre = pygame.display.set_mode((640, 480))
    pygame.display.set_caption("Le Saint Laurent")

    fond = pygame.image.load("TEX/MatR.png").convert()
    positionX = 0
    positionY = 0

    MatRSound = pygame.mixer.music.load("SON/MatR.wav")
    pygame.mixer.music.play()

    continuer = 1
    while continuer:
        fenetre.blit(fond, (positionX, positionY))
        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                continuer = 0
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    import MainMenu
                    Main = MainMenu()
                    Main.Afficher()
コード例 #13
0
    def setUp(self):
        global mConstructor
        global stateChanges
        mConstructor = MainMenu()
        stateChanges = ['menu', 'game', 'gameOver', 'gamePause', 'fakeMenu']

        pass
コード例 #14
0
ファイル: PiWeather.py プロジェクト: FacioErgoSum/ThePiWatch
def DisplayWeather():
    while 1 == 1:
        #Draw Background
        lcd.fill(GREY)
    
        #Set Icon
        if carbondale['current_conditions']['icon'] == 24 :
            iconimg = pygame.image.load('wind.png')
        elif carbondale['current_conditions']['icon'] == 14 :
            iconimg = pygame.image.load('snow.png')
        elif int(carbondale['current_conditions']['icon']) > 24 and int(carbondale['current_conditions']['icon']) < 32 :
            iconimg = pygame.image.load('cloudy.png')
        elif int(carbondale['current_conditions']['icon']) > 31 and int(carbondale['current_conditions']['icon']) < 35 :
            iconimg = pygame.image.load('clear-day.png')
        elif int(carbondale['current_conditions']['icon']) > 35 and int(carbondale['current_conditions']['icon']) < 41 :
            iconimg = pygame.image.load('rain.png')
        else :
            iconimg = pygame.image.load('unknown.png')

        #Draw Icon
        lcd.blit(iconimg, (16,16))

        #Grab Variables
        day = carbondale['forecasts'][0]['date'][4:]
        temperature = str(int((float(carbondale['current_conditions']['temperature'])*1.8)+32))
        dayofweek = carbondale['forecasts'][0]['day_of_week']
        text = carbondale['current_conditions']['text'][:7]
        chanceprecip = carbondale['forecasts'][0]['day']['chance_precip']
        high = str(int((float(carbondale['forecasts'][0]['high'])*1.8)+32))
        low = str(int((float(carbondale['forecasts'][0]['low'])*1.8)+32))

        #Write Temperature
        fontimg = bigFont.render(temperature + "F",1,WHITE)
        lcd.blit(fontimg, (145,38))

        #Write Day
        fontimg = mediumFont.render(dayofweek + " " + day,1,WHITE)
        lcd.blit(fontimg, (135,6))

        #Write Forecast
        fontimg = smallFont.render(text,1,WHITE)
        lcd.blit(fontimg, (23,118))

        #Write Chance of Rain
        fontimg = chanceFont.render("CoR: " + chanceprecip + "%",1,WHITE)
        lcd.blit(fontimg, (15,210))

        #Write High Temp
        fontimg = smallFont.render("Hi: " + high,1,WHITE)
        lcd.blit(fontimg, (141,117))

        #Write Low Temp
        fontimg = smallFont.render("Lo: " + low,1,WHITE)
        lcd.blit(fontimg, (225,117))

        pygame.display.update()

        if GPIO.input(k) == False:
            if k == 17:
                MainMenu.MenuButtons()
コード例 #15
0
 def __init__(self):
     self.showSplashScreen = True
     self.showMainMenu = False
     self.mainMenu = MainMenu.MainMenu()
     self.splashScreen = SirklesLogoScreen.SirklesLogoScreen()
     self.classicMode = ClassicMode.ClassicMode(self.mainMenu)
     self.gameplayMode = 0
     self.lightningMode = LightningMode.LightningMode(self.mainMenu)
コード例 #16
0
 def cancelCommand(self):
     Result = tkMessageBox.askquestion(
         "Cancel",
         "All information will be lost if you go back to main menu. Are You Sure?",
         icon='warning')
     if Result == 'yes':
         self.MainWindow.destroy()
         MainMenuWindow = MainMenu.MainMenuGUI()
コード例 #17
0
ファイル: Main.py プロジェクト: Veryyes/Day-of-Orion-III
    def __init__(self, screen):
        self.tick = 0
        self.running = True
        self.key_state = None
        self.state = State.MAIN_MENU

        self.context = MainMenu.MainMenu(lambda s: 0, lambda s: 0,
                                         lambda s: s.width, lambda s: s.height,
                                         screen)
コード例 #18
0
ファイル: LevelManager.py プロジェクト: talios0/Retalion
 def SetWindow(this, window):
     this.currentWindow = window
     if (window == 0):
         this.mainMenu = MainMenu(this.screen, this.events, this)
     elif (window == 1):
         this.game = Game(this.screen, this.events, this)
     elif (window == 2):
         this.gameOver = GameOver(this.screen, this.events, this,
                                  this.game.time)
コード例 #19
0
def menu_screen():
    run = True
    clock = pygame.time.Clock()

    while run:
        clock.tick(60)
        win.fill((128, 128, 128))
        MainMenu.mainMenu()
        pygame.display.update()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                run = False
            if event.type == pygame.MOUSEBUTTONDOWN:
                run = False

    main()
コード例 #20
0
 def open_main_menu(self, prev_window=None):
     """
     open main menu, deal with window stack
     """
     import MainMenu
     xbmc.executebuiltin("ActivateWindow(busydialog)")
     dialog = MainMenu.MainMenu(MAINMENU_XML, ADDON_PATH)
     xbmc.executebuiltin("Dialog.Close(busydialog)")
     self.open_dialog(dialog, prev_window)
コード例 #21
0
ファイル: main.py プロジェクト: JackD83/PyMenu
def init():
    lastRenderTime = 1

    Common.mountSD(True)

    # try:
    #     if(not Configuration.isOpenDinguX()):
    #         os.system('/usr/bin/retrofw network on')
    # except Exception as ex:
    #     pass

    realScreen = pygame.display.set_mode(
        (config["screenWidth"], config["screenHeight"]), HWSURFACE, 16)
    screen = pygame.Surface((config["screenWidth"], config["screenHeight"]))

    suspend = Suspend.Suspend()
    renderObject = MainMenu.MainMenu(screen, suspend)

    brightness = BrightnessVolumeControl.BrightnessVolume()

    while True:  # main game loop
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        suspend.handleEvents(events)
        renderObject.handleEvents(events)
        brightness.handleEvents(events)

        if (RenderControl.isDirty()):
            start = int(round(time.time() * 1000))
            RenderControl.setDirty(False)
            renderObject.render(screen)
            brightness.render(screen)

            if ("showFPS" in config["options"]
                    and config["options"]["showFPS"]):
                if (lastRenderTime == 0):
                    lastRenderTime = 1
                textSurface = textFont.render(
                    str(int(round(1000 / lastRenderTime))) + "fps ~" +
                    str(lastRenderTime) + "ms", True, (255, 255, 255))
                screen.blit(textSurface, (0, 0))
                #print("render time: " + str(lastRenderTime))

            realScreen.blit(screen, (0, 0))

            pygame.display.update()
            lastRenderTime = int(round(time.time() * 1000)) - start

        TaskHandler.updateTasks()
        fpsClock.tick(Common.getFPS())
コード例 #22
0
ファイル: LevelManager.py プロジェクト: talios0/Retalion
    def __init__(this, screen, events):
        ### Universal Components
        this.screen = screen
        this.events = events

        ### Window Options
        this.currentWindow = 0
        this.gameState = -1

        this.mainMenu = MainMenu(screen, events, this)
        this.game = this.mainMenu
        this.gameOver = GameOver(screen, events, this, 60)
コード例 #23
0
def main():
    root = Tk.Tk()
    # root.geometry("1024x768")

    root.attributes('-fullscreen', True)
    root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(),
                                       root.winfo_screenheight()))

    root.configure(bg="white")
    root.update()
    MainMenu.MainMenu(root)
    root.mainloop()
コード例 #24
0
ファイル: Main.py プロジェクト: PaskahAbr96/26414091
    def __init__(self):

        # Create PyHandler object
        self.Game = PyHandler.Main()
        self.Game.display((800, 600))

        self.MainMenu = MainMenu.MainMenu()

        self.Clock = pygame.time.Clock()  #Used to keep a constant frame-rate
        self.framerate = 200  #Frame-rate

        self.scene = 1
コード例 #25
0
def main():
    # create db tables
    initialize_tables()

    #create the application
    application = QApplication(sys.argv)

    #testing code to open up specific window from the start
    if len(sys.argv) > 1:
        if sys.argv[1] == 'edit':
            estack = EditStack()
            estack.create()
        elif sys.argv[1] == 'view':
            vstack = ViewStack()
            vstack.create()
    else:
        menu = MainMenu()
        menu.create()

    #wait for application to exit
    exitCode = application.exec_()
    sys.exit(exitCode)
コード例 #26
0
def init():
    lastRenderTime = 1
    setVolume()
    if (Configuration.isRS97() and platform.processor() == ""):
        realScreen = pygame.display.set_mode((320, 240), HWSURFACE, 16)
        screen = pygame.Surface(
            (config["screenWidth"], config["screenHeight"]))
    else:
        realScreen = pygame.display.set_mode(
            (config["screenWidth"], config["screenHeight"]), HWSURFACE, 16)
        screen = realScreen

    renderObject = MainMenu.MainMenu(screen)

    suspend = Suspend.Suspend()
    brightness = BrightnessVolumeControl.BrightnessVolume()

    while True:  # main game loop
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        suspend.handleEvents(events)
        renderObject.handleEvents(events)
        brightness.handleEvents(events)

        if (RenderControl.isDirty()):
            start = int(round(time.time() * 1000))
            RenderControl.setDirty(False)
            renderObject.render(screen)
            brightness.render(screen)

            if ("showFPS" in config["options"]
                    and config["options"]["showFPS"]):
                if (lastRenderTime == 0):
                    lastRenderTime = 1
                textSurface = textFont.render(
                    str(int(round(1000 / lastRenderTime))) + "fps ~" +
                    str(lastRenderTime) + "ms", True, (255, 255, 255))
                screen.blit(textSurface, (0, 0))
                print("render time: " + str(lastRenderTime))

            realScreen.blit(screen, (0, 0))

            pygame.display.update()
            lastRenderTime = int(round(time.time() * 1000)) - start

        TaskHandler.updateTasks()
        fpsClock.tick(Common.FPS)
コード例 #27
0
def updateResolution(cursor):
    #set resolution/mainmenu surface to global to be edited
    global mainMenuImage
    global resolution
    if cursor == 0:
        resolution = resolution1
    elif cursor == 1:
        resolution = resolution2
    elif cursor == 2:
        resolution = resolution3
    screen = pygame.display.set_mode(resolution)
    mainMenuImage = MainMenu.loadMainMenuBG(resolution)
    print('New Resolution:',resolution)
    return
コード例 #28
0
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.POS = POS().instance
        self.parent = parent

        # Thematic settings
        self.mainColor = "#99ccff"
        self.btnWidth1 = 20
        self.btnWidth2 = 10
        self.btnWidth3 = 40
        self.btnHeight1 = 1
        self.btnFontHeight1 = 9
        self.grey = "#818181"

        self.mainMenu = MainMenu(parent, self)
        self.loginWindow = LoginWindow(parent, self)
        self.transactionWindow = TransactionWindow(parent, self)
        self.manageUsers = ManageUsersWindow(parent, self)
        self.paymentWindow = PaymentWindow(parent, self)
        self.returnWindow = ReturnWindow(parent, self)
        self.rentalPaymentWindow = RentalPaymentWindow(parent, self)

        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)

        self.mainMenu.place(x=0, y=0, relwidth=1, relheight=1)
        self.loginWindow.place(x=0, y=0, relwidth=1, relheight=1)
        self.transactionWindow.place(x=0, y=0, relwidth=1, relheight=1)
        self.manageUsers.place(x=0, y=0, relwidth=1, relheight=1)
        self.paymentWindow.place(x=0, y=0, relwidth=1, relheight=1)
        self.returnWindow.place(x=0, y=0, relwidth=1, relheight=1)
        self.rentalPaymentWindow.place(x=0, y=0, relwidth=1, relheight=1)

        self.loginWindow.lift()

        self.initUI()
コード例 #29
0
def Main():
    #Set up the other classes
    MainMenu.main()
    ReversiGrid.main()

    #Generate a random board
    Gamestate = BoardGenerator.generate(False, False)

    #Place the pieces from the random board
    StringInterpret.StringToPiece(Gamestate, 0)

    #Place starting config
    Gamestate = StringInterpret.StringInterpret(Gamestate, "D4", 0)
    Gamestate = StringInterpret.StringInterpret(Gamestate, "E4", 1)
    Gamestate = StringInterpret.StringInterpret(Gamestate, "E5", 2)
    Gamestate = StringInterpret.StringInterpret(Gamestate, "D5", 3)

    #Keeps track of how many moves have been made
    move_num = 4

    #Loop until board is full
    while VictoryStatus.is_game_over(Gamestate) == False:
        #Get validated player move
        move = StringMove.get_move(Gamestate, "Please enter a move:")

        #If the player didn't hit cancel
        if move != "invalid":
            Gamestate = StringInterpret.StringInterpret(
                Gamestate, move, move_num)
            move_num += 1

    #Print who won
    print(PlayerVictory.PlayerWon(Gamestate))

    #Wait for user
    Constants.WINDOW.exitonclick()
コード例 #30
0
ファイル: Credits.py プロジェクト: tecprog16-2/FoF
   def hidden(self):
       """
 If a sound is being played in the credits
 the following control structure decreases its volume
 gradually.
 Otherwise the control structure calls the methods
 removing the possibility of the player using a key
 the control and what he calls the main menu.
   """
       if self.song:
           self.song.fadeout(1000)
       else:
           pass
       self.engine.input.removeKeyListener(self)
       self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
コード例 #31
0
ファイル: GameLayer.py プロジェクト: CritBear/PeacefulVillage
def game_over():
    w, h = director.get_window_size()
    layer = cocos.layer.Layer()
    text = cocos.text.Label('Game Over',
                            position=(w * 0.5, h * 0.5),
                            font_name='Oswald',
                            font_size=72,
                            anchor_x='center',
                            anchor_y='center')

    layer.add(text)
    scene = cocos.scene.Scene(layer)
    new_scene = FadeTransition(MainMenu.new_menu())
    func = lambda: director.replace(new_scene)
    scene.do(ac.Delay(3) + ac.CallFunc(func))
    return scene
コード例 #32
0
ファイル: Main.py プロジェクト: blacknight0117/Bodulfr
def main():

    pygame.init()

    Vars.DISPLAYSURF = pygame.display.set_mode((Vars.WINWIDTH, Vars.WINHEIGHT))
    Vars.FPSCLOCK = pygame.time.Clock()

    SplashScreen()
    IntroVids()
    InitConts()

    extras = MainMenu.main()
    print(extras)
    if extras == 'dev':
        Game.mainLoop('dev')
    else:
        Game.mainLoop('')
コード例 #33
0
ファイル: main.py プロジェクト: Toshibane/UniverseGenesis
def start(screen):
    """Fonction s'occupant rapidement de la boucle de jeu"""
    state = ["read_scene", 'super_choice', '']
    in_game = True
    while in_game:
        if state[0] == "quit":
            in_game = False
        elif state[0] == "main_menu":
            menu = MainMenu.MainMenu(screen)
            state = menu.start()
        elif state[0] == "read_scene":
            json_scene = utils.load_scene(state[1])
            menu = None
            if json_scene["type"] == "choice":
                menu = ReadChoice(screen, state[1], state[2])
            else:
                menu = ReadScene(screen, state[1], state[2])
            state = menu.start()
コード例 #34
0
ファイル: GameOver.py プロジェクト: Andoree/Python-Study
    def load(game_name, score):
        score_text = 'Your score ' + score
        text = (
            None,
            (("GAME OVER", -1, title_font, 150), (score_text, -1,
                                                  subtitle_font, 200),
             ("Press enter button to continue", -1, text_font, 350)),
        )
        pygame.display.set_caption(game_name)
        # An: screen_size hardcode fixed
        screen = pygame.display.set_mode(
            (Game.screen_width, Game.screen_height), 0, 32)
        bg = pygame.image.load("data/menu/bg.png")
        WHITE = (255, 255, 255)
        # An: screen_size hardcode fixed
        info_rect = pygame.Rect((0, 0, Game.screen_width, Game.screen_height))
        info = MainMenu.Info(info_rect, WHITE, bg, text)
        info.update(1)
        screen.blit(bg, (0, 0))
        screen.blit(info.surf, info_rect)

        pygame.display.flip()

        running = True
        name = ""
        input_rect = pygame.Rect((25, 275, screen.get_width() - 50, 50))
        font = pygame.font.Font(None, 40)
        while running:
            name, state = check_input(name, pygame.event.get())
            if state == 4:
                return 4, -1
            elif state == 1:
                return 1, name
            # surf = pygame.Surface((550, 50))
            # An: white
            text = font.render("Write your name: " + name, 1, WHITE)
            # surf.blit(text, ((surf.get_width() - text.get_width()) / 2, (surf.get_height() - text.get_height()) / 2))
            # screen.blit(surf, input_rect)
            screen.blit(bg, (0, 0))
            x_pos = (input_rect.width - text.get_width()) / 2
            y_pos = input_rect.topleft[1] + (input_rect.height -
                                             text.get_height()) / 2
            screen.blit(text, (x_pos, y_pos))
            pygame.display.update(input_rect)
コード例 #35
0
ファイル: Rules.py プロジェクト: Inderpreet-D/CPSC231-Reversi
def displayRules():
    #Get the window and turtle
    turtle = Constants.TURTLE

	#Create a list for holding the rules
    rules = []
    rules.append("Reversi is a 2 player game that is played on an 8 x 8 grid. \n \n")
    rules.append("The game discs have both a black and white side. \n \n")
    rules.append("To win you have to have the majority of the discs changed to your color at the end of the game. \n \n")
    rules.append("The game ends when there are no more possible moves to make. \n \n ")
    rules.append("The game can end before the entire grid is filled. \n \n ")
    rules.append("Players take turns placing discs, with their color facing up. \n \n ")
    rules.append("When a player places a disk on the board, all the pieces that are between that player's newly placed disc \n and any of their previously placed discs, are turned to that player's color. \n")
    rules.append("When placing your discs on your turn, there has to be at least one piece of the opposite colour between \n your placed piece and any of your previously placed pieces. Otherwise the move is not valid. ")
    rules.append("The placed pieces have to make either a horizontal, vertical or diagonal line with the opposing player's discs to flip any pieces over.")

	#Move the turtle to the appropriate location for the rules output
    line = Constants.RULES_LINESTARTY
    MainMenu.moveTurtle(turtle, Constants.TITLE_LOCATIONX, Constants.RULES_LINESTARTY)

	#Go through the rules list
    for r in range(len(rules)):
        #Each loop moves the next rule down 30 units
        line -= 55

        #Move the turtle
        MainMenu.moveTurtle(turtle, Constants.RULES_LINESTARTX, line)

        #Format the line
        rule = "\n" + str(r + 1) + ") " + rules[r]

        #Draw the rule
        turtle.write(rule, False, align = "left", font = ("Arial", 10, "normal"))

        #Move back to the start of the line
        MainMenu.moveTurtle(turtle, Constants.RULES_LINESTARTX, line)

    #Draw a button
    MainMenu.drawButton(turtle, Constants.BACK_BUTTON_LEFT_X, Constants.BACK_BUTTON_TOP_Y, "Back")
コード例 #36
0
 def test_constructor(self) :
     testObj = MainMenu()
     self.assertEquals(str(mConstructor),str(testObj))
     testObj.changeState('gameOver')
     self.assertNotEquals(str(mConstructor),str(testObj))
コード例 #37
0
ファイル: MC_onebase.py プロジェクト: evancaseydev/MC-Repo
def play():
    SCREEN_SIZE = (500, 500)
    height = SCREEN_SIZE[1]
    width = SCREEN_SIZE[0]
    DISPLAYSURF = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
    pygame.display.set_caption("Missile Command")
    pygame.mouse.set_visible(True)
    fontObj = pygame.font.Font("Fonts/freesansbold.ttf", 30)
    smallfontObj = pygame.font.Font("Fonts/freesansbold.ttf", 18)

    FPS = 60
    myClock = pygame.time.Clock()
    shootCooldown = 50
    origCooldown = 50
    powercooldown = 0
    tick = shootCooldown
    counter = 0
    rapidCool = 5
    missileTimer = 75
    missilesToFire = 10
    missilesFired = 0
    score = [0]
    launchAmmo = 15
    levelCount = 0
    enemyspeed = [1, 10]
    supersonic = bigexplosions = rapid = flak = False
    prices = [750, 500, 400, 450, 500]
    duration = 300

    WHITE = (255, 255, 255)
    BLACK = (0, 0, 0)
    RED   = (255, 0, 0)
    GREEN = (0, 255, 0)
    BLUE = (0, 0, 255)

    cityXCoords = [25, 75, 125, 250 + 125 + 63, 250 + 75 + 63, 250 + 25 + 63]
    launchx = (width / 2) - (63 / 2)
    launchy = height - 29

    missiles = []
    launchsites = []
    cities = []
    explosions = []
    powerups = []
    pointorbs = []
    radius = [10]
    availPowers = ["Missile +10", "ATOMIC BOMB", "Rapid Fire", "Huge Explosions", "Supersonic Missiles", "Flak Cannon"]
    possibleCoords = cityXCoords[:]
    for i in range(len(possibleCoords)):
        possibleCoords[i] += 21
                
    possibleCoords.append(launchx + (63 / 2))
    activePower = []

    launchsite = LaunchSite((launchx, launchy), launchAmmo, height)
    launchsites.append(launchsite)
    gameover = fontObj.render("GAME OVER", True, RED)
    nextlevel = fontObj.render("LEVEL 1", True, BLUE)

    for x in cityXCoords:
        cities.append(City.City((x, launchy + 2)))
        
    while True:
        rad = 0
        if tick > shootCooldown:
            rad = 5
        nomissilesleft = True
        variant = 0

        if levelCount >= 2:
            if random.randrange(20) == 1:
                variant = 1

        if powercooldown == 0:
            supersonic = bigexplosions = rapid = flak = False
            
        missilesLeft = fontObj.render(str(launchsite.numMissiles), True, RED)
        scoreText = fontObj.render(str(score[0]), True, BLUE)
        DISPLAYSURF.fill(WHITE)
        DISPLAYSURF.blit(launchsite.image, launchsite.location)
        DISPLAYSURF.blit(missilesLeft, (width - (20 * len(str(launchsite.numMissiles))), 0))
        DISPLAYSURF.blit(scoreText, (0, 0))
        pygame.draw.circle(DISPLAYSURF, RED, (launchsite.rect.center[0] + 1, launchsite.rect.center[1]), rad, 0)

        if powercooldown > 0:
            if powercooldown <= 254:
                color = powercooldown
            else:
                color = 255
            pygame.draw.circle(DISPLAYSURF, (0, color, 0), (width / 2, 11), 10, 0)

            
        if random.randrange(500) == 1 and len(powerups) == 0 and powercooldown == 0:  
            powerups.append(Powerup.Powerup(random.randrange(width - 20), random.randrange(0, len(availPowers)), height, 1))

        if random.randrange(1250) == 1 and len(pointorbs) == 0:
            pointorbs.append(PointOrb.PointOrb(height, width))

        for power in activePower:
            powercooldown = duration
            powertext = fontObj.render(power + "!", True, GREEN)
            if power == "Supersonic Missiles":
                supersonic = True
            elif power == "Missile +10":
                launchsite.numMissiles += 10
            elif power == "ATOMIC BOMB":
                explosions.append(Explosion.Explosion((width / 2, height / 2), True, "nuke", False, radius[0], cities, missiles, powerups, launchsites))
                score[0] += 100
            elif power == "Huge Explosions":
                bigexplosions = True
            elif power == "Rapid Fire":
                rapid = True
            elif power == "Flak Cannon":
                flak = True
            activePower.remove(power)

        if counter % missileTimer == 0 and not missilesFired == missilesToFire:
            enemyFire(possibleCoords, variant, missiles, height, width, enemyspeed)
            missilesFired += 1
            
        for city in cities:
            DISPLAYSURF.blit(city.image, city.location)

        if flak and random.randrange(20) == 1:
            explosions.append(Explosion.Explosion((random.randrange(10, width - 10), random.randrange(10, height - 50)), True, "norm", False, radius[0], cities, missiles, powerups, launchsites))
            explosions[-1].growthTime += 10
            
        for missile in missiles:
            if not missile.done:
                display = missile.update(explosions, height, radius, cities, missiles, powerups, launchsites, possibleCoords)
                nomissilesleft = False
                pygame.draw.line(DISPLAYSURF, display[0], display[1], display[2], display[3])
                    
        for explosion in explosions:
            display = explosion.update(cities, missiles, powerups, launchsites, explosions, score, possibleCoords, activePower, pointorbs)
            pygame.draw.circle(DISPLAYSURF, display[0], display[1], display[2], display[3])

        for power in powerups:
            display = power.update(powerups)
            DISPLAYSURF.blit(display[0], display[1])

        for orb in pointorbs:
            orb.update(pointorbs, DISPLAYSURF, height, width)

        if powercooldown > 225:
            DISPLAYSURF.blit(powertext, ((width / 2) - 100, (height / 2)))
        
        for event in pygame.event.get():
            keys = pygame.key.get_pressed()
            if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
                outfile = open("Data/highscores.txt", "a")
                outfile.write(str(score[0] * (levelCount + 1)) + ", ")
                outfile.close()
                import MainMenu
                MainMenu.startMenu()
            if event.type == pygame.MOUSEBUTTONDOWN and not rapid:
                pos = pygame.mouse.get_pos()
                if not launchsite.numMissiles == 0 and tick > shootCooldown and not launchsite.dead:
                    launchsite.shoot(pos, supersonic, bigexplosions, 0, missiles, enemyspeed)
                    tick = 0

        if rapid and tick % rapidCool == 0:
            launchsite.shoot(pygame.mouse.get_pos(), supersonic, bigexplosions, 0, missiles, enemyspeed)
            launchsite.numMissiles += 1
            
        if launchsite.dead:
            deadCount = 0
            for city in cities:
                if city.dead:
                    deadCount += 1
            if deadCount == len(cities):
                finalscore = fontObj.render("Score: " + str(score[0] * (levelCount + 1)), True, RED)
                time.sleep(3)
                DISPLAYSURF.fill(BLACK)
                DISPLAYSURF.blit(gameover, (width / 2 - 85, (height / 2) - 35))
                DISPLAYSURF.blit(finalscore, (width / 2 - 85, height / 2))
                pygame.display.update()
                time.sleep(3)
                outfile = open("Data/highscores.txt", "a")
                outfile.write(str(score[0] * (levelCount + 1)) + ", ")
                outfile.close()
                import MainMenu
                MainMenu.startMenu()

        if missilesFired == missilesToFire and nomissilesleft and len(explosions) == 0:
            time.sleep(2)
            levelCount += 1
            viewscores = True
            aliveCount = 0
            launchsite.dead = False
            for city in cities:
                if not city.dead:
                    aliveCount += 1

            citybonus = smallfontObj.render("Cities Alive:  " + str(aliveCount), True, BLUE)
            missilesbonus = smallfontObj.render("Missiles Left: " + str(launchsite.numMissiles), True, BLUE)
            finalbonus = smallfontObj.render("Bonus: " + str(aliveCount * 50) + " + " + str(launchsite.numMissiles * 5) + " = " + str((launchsite.numMissiles * 5) + (aliveCount * 50)), True, BLUE)
            nextlevel = fontObj.render("LEVEL " + str(levelCount), True, BLUE)

            powercooldown = 0
            supersonic = bigexplosions = rapid = False
            shootCooldown = origCooldown
            score[0] += (aliveCount * 50)
            score[0] += (launchsite.numMissiles * 5)
            cities[:] = []
            missiles[:] = []
            explosions[:] = []
            powerups[:] = []
            activePower[:] = []
            launchsites[:] = []
            pointorbs[:] = []
            possibleCoords[:] = cityXCoords
            for x in cityXCoords:
                cities.append(City.City((x, launchy + 2)))

            for i in range(len(possibleCoords)):
                possibleCoords[i] += 21
            possibleCoords.append(launchx + (63 / 2))

            while viewscores:
                DISPLAYSURF.fill((255, 255, 255))
                DISPLAYSURF.blit(nextlevel, ((width / 2) - 85, (height / 2) - 80))
                DISPLAYSURF.blit(citybonus, ((width / 2) - 85, (height / 2) - 40))
                DISPLAYSURF.blit(missilesbonus, ((width / 2) - 85, (height / 2) - 20))
                DISPLAYSURF.blit(finalbonus, ((width / 2) - 85, (height / 2)))
                for event in pygame.event.get():
                    if event.type == KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN:
                        viewscores = False
                myClock.tick(FPS)
                pygame.display.update()

            shootCooldown = [shootCooldown]
            launchAmmo = [launchAmmo]
            duration = [duration]
            shop(DISPLAYSURF, myClock, 1.2, shootCooldown, radius, enemyspeed, launchAmmo, score, prices, duration)
            launchAmmo = launchAmmo[0]
            shootCooldown = shootCooldown[0]
            duration = duration[0]
            
            missilesFired  = 0
            missilesToFire = int(1.3 * float(missilesToFire))
            launchAmmo = int(1.2 * float(launchAmmo))
            launchsite = LaunchSite((launchx, launchy), launchAmmo, height)
            launchsites.append(launchsite)
            if levelCount % 2 == 0: # every other level enemy missile speed increases
                enemyspeed[0] += .5
            if levelCount % 3 == 0 and missileTimer >= 45: # every second level enemy missile frequency increases
                missileTimer -= 5

            pygame.display.update()
            
        if powercooldown > 0:
            powercooldown -= 1
        tick += 1
        counter += 1
        myClock.tick(FPS)
        pygame.display.update()
コード例 #38
0
def main():
    pygame.init()
    print "Pygame Initialized"
    pygame.display.set_caption("PyGame Tower Defence Game")
    pygame.mouse.set_visible(1)
    #localdefs: mapvar = Map()
    
    print "Map Object Generated"
    screen = pygame.display.set_mode((scrwid,scrhei))
    print "Display Initialized"
    clock = pygame.time.Clock()

    player.start()
    player.addScreen(screen,clock)

    background = mapvar.loadMap((scrwid,scrhei),MainMenu.main(screen,clock))

    genEnemyImageArray()
    run=True #Run loop
    wavenum = 0
    selected = None #Nothing is selected

    MainFunctions.makeIcons()
    
    print "Begin Play Loop!!!"

    font = pygame.font.Font(None,20)
    speed = 3
    frametime = speed/30.0
    while run:
#        timehold = list()
        starttime = time.time()
#        temptime = time.time()

        MainFunctions.tickAndClear(screen, clock, background, frametime)
#        timehold.append(("tAC",time.time()-temptime))
#        temptime = time.time()

        MainFunctions.workSenders(frametime)
#        timehold.append(("wSe",time.time()-temptime))
#        temptime = time.time()

        MainFunctions.workTowers(screen,frametime)
#        timehold.append(("wTo",time.time()-temptime))
#        temptime = time.time()

        MainFunctions.dispExplosions(screen,frametime)
#        timehold.append(("dEx",time.time()-temptime))
#        temptime = time.time()

        MainFunctions.dispText(screen,wavenum)
#        timehold.append(("dTe",time.time()-temptime))
#        temptime = time.time()

        MainFunctions.workEnemies(screen,frametime)
#        timehold.append(("wEn",time.time()-temptime))
#        temptime = time.time()

        screen,selected,wavenum,speed,timedel = MainFunctions.workEvents(screen, frametime, selected, wavenum, Sender, speed,pygame.font.Font(None,30),pygame.font.Font(None,25))
#        timehold.append(("wEv",time.time()-temptime))
#        temptime = time.time()

        starttime += timedel

        MainFunctions.dispStructures(screen,pygame.mouse.get_pos())
#        timehold.append(("dSt",time.time()-temptime))
#        temptime = time.time()

        screen.blit(mapvar.baseimg,mapvar.baserect)

        if selected and selected.__class__ == Icon:
            MainFunctions.selectedIcon(screen, selected)
#            timehold.append(("sIc",time.time()-temptime))
#            temptime = time.time()

        if selected and Tower is selected.__class__:
            MainFunctions.selectedTower(screen,selected,pygame.mouse.get_pos())
#            timehold.append(("sTo",time.time()-temptime))
#            temptime = time.time()

        screen.blit(openbuttoninfo[0],openbuttoninfo[1])

        MainFunctions.dispIcons(screen, pygame.mouse.get_pos(), font, frametime)
#        timehold.append(("dIc",time.time()-temptime))

        pygame.display.flip()

        frametime = (time.time() - starttime) * speed
コード例 #39
0
ファイル: BabyDaddy.py プロジェクト: word-dudely/Baby-Daddy
def main():
    #window stuff
    pygame.init()
    if (WINDOWED):screen = pygame.display.set_mode(SCREEN_SIZE)
    else:screen = pygame.display.set_mode(SCREEN_SIZE, FULLSCREEN)
    pygame.display.set_icon(pygame.image.load(ICON))
    pygame.display.set_caption(TITLE_BAR_TEXT)
    #repeat keydowns
    pygame.key.set_repeat(40,40)
    #load the clock for the framerate
    clock = pygame.time.Clock()
    #set the initial volume based on the constants
    if SOUND_ENABLED:pygame.mixer.music.set_volume(GLOBAL_MUSIC_VOLUME)
    else:pygame.mixer.music.set_volume(0)
    #main game surface
    screen_surface = pygame.Surface(screen.get_size())
    screen_surface_rect = screen_surface.get_rect()
    #states
    gameState=MAIN_MENU
    daddyState=[STAND,SOUTH]
    babyState=IDLE
    stateCache=MAIN_MENU
    #sprites
    menu=MainMenu()
    game=GameScene()
    gameOver=GameOver()
    soundBtn=SoundBtn()
    pauseScreen=PauseScreen()
    pauseContainer=pygame.sprite.GroupSingle()
    #and the program container
    spriteContainer=pygame.sprite.GroupSingle()
    
    
    
    def toggleSound():
        soundOn=pygame.mixer.music.get_volume()
        if soundOn:
            pygame.mixer.music.set_volume(0)
            soundBtn.image=pygame.image.load('images/sound_off.png').convert_alpha()
        else:
            pygame.mixer.music.set_volume(GLOBAL_MUSIC_VOLUME)
            soundBtn.image=pygame.image.load('images/sound_on.png').convert_alpha()
        spriteContainer.draw(screen_surface)
        soundBtnContainer.draw(screen_surface) 
        screen.blit(screen_surface, (0,0))
        pygame.display.flip()
        writeConfig()

    def changeMusic(newTrack, volume=GLOBAL_MUSIC_VOLUME):
        soundOn=pygame.mixer.music.get_volume()
        pygame.mixer.music.load('audio/'+newTrack)
        pygame.mixer.music.play(-1)
        if (soundOn):pygame.mixer.music.set_volume(volume)
        else:pygame.mixer.music.set_volume(0)
        
        
    def createMenu():
        pygame.time.set_timer(USEREVENT+1, 0)
        spriteContainer.add(menu)
        spriteContainer.draw(screen_surface)
        soundBtnContainer.draw(screen_surface)
        screen.blit(screen_surface, (0,0))
        pygame.mixer.music.fadeout(50)
        pygame.display.flip()
        changeMusic('babyDaddyHookRepeat.ogg')
        
    def startGame():
        spriteContainer.add(game)
        spriteContainer.draw(screen_surface)
        screen.blit(screen_surface, (0,0))
        pygame.mixer.music.fadeout(50)
        changeMusic('babyDaddyMainLoop.wav')
        pygame.display.flip()
        pygame.time.set_timer(USEREVENT+1, 1500)
        pygame.time.set_timer(USEREVENT+2, 10000)
        game.startGame()
    
    def createGameOver():
        spriteContainer.add(gameOver)
        spriteContainer.draw(screen_surface)
        screen.blit(screen_surface, (0,0))
        pygame.time.set_timer(USEREVENT+1, 0)
        pygame.time.set_timer(USEREVENT+2, 0)
        changeMusic('Sad_Male.ogg')
        pygame.display.flip()
        
    #display soundBtn
    soundBtn.rect.bottomright = screen_surface_rect.bottomright
    soundBtn.rect=soundBtn.rect.move(-15,-15)
    soundBtnContainer=pygame.sprite.GroupSingle(soundBtn)  
    #display menu
    createMenu()
    
    def writeConfig():
        #print(pygame.mixer.music.get_volume()==GLOBAL_MUSIC_VOLUME)
        f=open('Config.py', 'w')
        f.write('#sound\nSOUND_ENABLED='+str(pygame.mixer.music.get_volume()==GLOBAL_MUSIC_VOLUME))
        f.close()
    
    #state machine/infinite loop. This may get messy...
    while True:
        #set the framerate
        clock.tick(60)
        for event in pygame.event.get():
            if event.type == ACTIVEEVENT:
                #if game is out of focus or minimized, pause
                if (event.state==2) | ((event.state==6) & (event.gain==0)):
                    tempSndState=pygame.mixer.music.get_volume()
                    stateCache=gameState
                    gameState=PAUSED
                    pauseContainer.add(pauseScreen)
                    pauseContainer.draw(screen_surface)
                    screen.blit(screen_surface, (0,0))
                    pygame.mixer.music.set_volume(0)
                    pygame.display.flip()
                #back in the game
                elif (event.state==6)&(event.gain==1):
                    pygame.mixer.music.set_volume(tempSndState)
                    gameState=stateCache
                    pauseContainer.empty()
                    spriteContainer.draw(screen_surface)
                    screen.blit(screen_surface, (0,0))
                    pygame.display.flip()
            if event.type == QUIT:
                sys.exit(0)
            if event.type == MOUSEBUTTONDOWN:
                x,y = event.pos
                if soundBtn.rect.collidepoint(x,y):
                    toggleSound()
            if ((event.type == MOUSEBUTTONDOWN) & (gameState==MAIN_MENU)):
                x,y = event.pos
                if menu.startBtn_rect.collidepoint(x,y):
                    startGame()
                    gameState=GAME_ON
                if menu.exitBtn_rect.collidepoint(x,y):
                    sys.exit(0)
            if ((event.type == MOUSEBUTTONDOWN) & (gameState==GAME_OVER)):
                createMenu()
                gameState=MAIN_MENU
            if ((event.type == KEYDOWN) & (gameState==GAME_ON)):
                keys=pygame.key.get_pressed()
                if (keys[K_RIGHT] | keys[K_d]):
                    daddyState = [WALK,EAST]
                if (keys[K_DOWN] | keys[K_s]):
                    daddyState = [WALK,SOUTH]
                if (keys[K_LEFT] | keys[K_a]):
                    daddyState = [WALK,WEST]
                if (keys[K_UP] | keys[K_w]):
                    daddyState = [WALK,NORTH]
                if ((keys[K_UP] & keys[K_RIGHT]) | (keys[K_w] & keys[K_d])):
                    daddyState = [WALK,NORTHEAST]
                if ((keys[K_UP] & keys[K_LEFT]) | (keys[K_w] & keys[K_a])):
                    daddyState = [WALK,NORTHWEST]
                if ((keys[K_DOWN] & keys[K_RIGHT]) | (keys[K_s] & keys[K_d])):
                    daddyState = [WALK,SOUTHEAST]
                if ((keys[K_DOWN] & keys[K_LEFT]) | (keys[K_s] & keys[K_a])):
                    daddyState = [WALK, SOUTHWEST]
                game.daddy.moveDaddy(daddyState, game.baby.rect)
            if ((event.type == KEYUP) & (gameState==GAME_ON)):
                if event.key == K_SPACE:
                    game.shootDaddy()
                if event.key == K_ESCAPE: 
                    createMenu()
                    gameState=MAIN_MENU
                else:
                    daddyState[0] = STAND
                    if (daddyState[1]==NORTHEAST) | (daddyState[1]==NORTHWEST): daddyState[1]=NORTH
                    if (daddyState[1]==SOUTHEAST) | (daddyState[1]==SOUTHWEST): daddyState[1]=SOUTH
                    game.daddy.moveDaddy(daddyState, game.baby.rect)
            if ((event.type==USEREVENT+1)&(gameState==GAME_ON)):
                game.launchEnemy()
            if ((event.type==USEREVENT+2)&(gameState==GAME_ON)):
                game.randomItem()
        if gameState==MAIN_MENU:
            pygame.time.delay(200)
            menu.update()
            spriteContainer.draw(screen_surface)
            soundBtnContainer.draw(screen_surface)  
            screen.blit(screen_surface, (0,0))
            pygame.display.flip()
        if gameState==GAME_ON:
            game.update()
            spriteContainer.draw(screen_surface)
            soundBtnContainer.draw(screen_surface)  
            screen.blit(screen_surface, (0,0))
            pygame.display.flip()
            if ((game.numDH==0) | (game.numBH<=0)):
                createGameOver()
                gameState=GAME_OVER
コード例 #40
0
#Game_Logic.move_unit("Tank", (3,3), (16, 16))

while True:



    if config.window == "MainMenu":
        #pygame.mixer.music.stop()
        if config.firsttime:
            if config.music == True:
                Music.MenuMusic()
            else:
                pygame.mixer.music.stop()
            config.firsttime = False
        MainMenu.game_intro()
    if config.window == "PlayerMenu":
        PlayerMenu.secondscreen()
    if config.window == "PlayerNameMenu":
        PlayerNameMenu.thirdscreen()
    if config.window == "SettingMenu":
        SettingMenu.settingscreen()
    if config.window == "terminationmenu":
        EndingMenu.endscreen()



    if config.window == "Main":
        #if config.mapArray[7][1].troops != []:
        #    if config.mapArray[7][1].troops[0].troops != []:
        #        print(config.mapArray[7][1].troops[0].troops[0].Name)