while carryOn: clock.tick(60) # === Deal with top-level events === for event in pygame.event.get(): if event.type == pygame.QUIT: carryOn = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_x: carryOn = False # === User input handling === keys = pygame.key.get_pressed() if keys[pygame.K_w]: playerRocket.moveUp(10) elif keys[pygame.K_s]: playerRocket.moveDown(10) if keys[pygame. K_SPACE]: # This is an if so you can hold spacebar and move. if newLaser.fired == False: effect = pygame.mixer.Sound('laser.wav') effect.set_volume(1) effect.play() newLaser.fire(playerRocket.rect.x, playerRocket.rect.y + playerRocket.height // 2) # Creates boundaries by moving in the opposite direction, at the same speed so the rocket can't move past these points if playerRocket.rect.y == 105: playerRocket.moveDown(10) if playerRocket.rect.y == 555: