コード例 #1
0
             #FIXED BUG: if statement is used to fix the error in the rare case the key_name is not already in keyPressed
             if (key_name in keyPressed):
                 #removes the key name to keyPressed
                 keyPressed.remove(key_name)
             #stops playing rocket sound
             SOUND_ROCKET.stop()
 #Here's where all the code for the INTRO screen lies
 if (player.screenType == ScreenType.INTRO):
     #initialize changeTitleColor and Clock
     changeTitleColor = False
     CLOCK = pygame.time.Clock()
     #timer to change title color
     if (pygame.time.get_ticks() % 2000 == 0):
         changeTitleColor = True
     #draw intro screen
     RenderUtils.drawIntro(clicking, changeTitleColor)
     #FIXED BUG: resets keyPressed because sometimes pygame never calls the keyUp event,
     #leading the program to think the key is pressed when it isn't.
     keyPressed = []
     #FIXED BUG: speed values didn't reset for new game
     yawSpeed = 0
     pitchSpeed = 0
     rollSpeed = 0
     speed = 0
 #Here's where all the code for the GAME screen lies
 elif (player.screenType == ScreenType.GAME):
     player.z += speed
     #Matrix Transformations(3D rotations)
     transformAll(yawSpeed, "Y")
     transformAll(pitchSpeed, "X")
     transformAll(rollSpeed, "Z")