Example #1
0
def cpuEvents():
    global mode, display_width, display_height, winMode, gameDisplay, fullscreenStat

    for event in pygame.event.get(): 

            if event.type == pygame.KEYDOWN:
        
                if event.key == pygame.K_e: #E to change mode
                            mode = "Player"
                if event.key == pygame.K_ESCAPE: #Escape pauses game
                        menuv2.pauseMenu()
                if event.key == pygame.K_p: #P for fullscreen lol
                        
                        if fullscreenStat == True: #Toggle fullscreen off
                             
                                winMode = pygame.DOUBLEBUF | pygame.HWSURFACE
                                display_width = 1200
                                display_height = 800
                                gameDisplay = pygame.display.set_mode((display_width, display_height),winMode)
                                fullscreenStat = False
                        else: #Toggle fullscreen on
                           
                                winMode = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN #Set display variable to include fullscreen
                                display_width = 1200
                                display_height = 800
                                gameDisplay = pygame.display.set_mode((display_width, display_height),winMode) #Generate new display fullscreen
                                #player.reload()
                                fullscreenStat = True
        
        #Allows a user to close the window using the close button
            if event.type == pygame.QUIT:
                os.execl(sys.executable, sys.executable, * sys.argv)
Example #2
0
 if event.key == pygame.K_a: #A button turns ship left
         player.rotL()
 if event.key == pygame.K_d: #D button turns ship right
         player.rotR()
 if event.key == pygame.K_w: #W accelerates the ship
         player.fwd()
 if event.key == pygame.K_s: #S deccelerates ship
         player.bwd()
 if event.key == pygame.K_m: #M mines a planet if nearby
             mine(mineArg[0],mineArg[1],mineArg[2],mineArg[3])
             mineText = "Press M to mine"
 if event.key == pygame.K_e and fuel > 0: #Switches to CPU control mode (but prevents this on GameOver)
             mode = "CPU"
             fuel = 100
 if event.key == pygame.K_ESCAPE: #Escape to pause
         menuv2.pauseMenu()
 if event.key == pygame.K_p: #P for fullscreen
         
         if fullscreenStat == True:
              
                 winMode = pygame.DOUBLEBUF | pygame.HWSURFACE
                 display_width = 1200
                 display_height = 800
                 gameDisplay = pygame.display.set_mode((display_width, display_height),winMode)
                 fullscreenStat = False
         else:
            
                 winMode = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN #Set display variable to include fullscreen
                 display_width = 1200
                 display_height = 800
                 gameDisplay = pygame.display.set_mode((display_width, display_height),winMode) #Generate new display fullscreen