Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tearDown(self):
pygame.quit()
def wait_for_key():
# utility function to pause waiting for a keypress
# still allow Esc to exit
# Actually, we look for KEYUP event, not KEYPRESS
if len(pygame.event.get(pygame.QUIT)) > 0:
pygame.quit()
sys.exit()
keyup_events = pygame.event.get(pygame.KEYUP)
if len(keyup_events) == 0:
return None
if keyup_events[0].key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
return keyup_events[0].key
while going:
# handle input events
for event in pygame.event.get():
if event.type == QUIT:
going = False
group.update(event)
group.draw(screen, background)
pygame.display.update()
pygame.time.wait(100)
except Exception:
# in case something does not work out...
import traceback
print("Something has gone wrong...")
print(traceback.format_exc())
finally:
pygame.quit()
sys.exit()
frame = self._kinect.get_last_infrared_frame()
self.draw_infrared_frame(frame, self._frame_surface)
frame = None
self._screen.blit(self._frame_surface, (0,0))
pygame.display.update()
# --- Go ahead and update the screen with what we've drawn.
pygame.display.flip()
# --- Limit to 60 frames per second
self._clock.tick(60)
# Close our Kinect sensor, close the window and quit.
self._kinect.close()
pygame.quit()
def terminate():
pygame.quit()
sys.exit()
def terminate():
pygame.display.quit(); pygame.quit() # Display quit is a workaround for a Raspberry Pi bug.
sys.exit()
def quit(self):
pygame.quit()
sys.exit()
def quit(self):
sleep(1)
pygame.quit()
sys.exit(1)
def start_loop(self):
controller = controllers.WorldController(self)
while controller.handle_input():
controller.handle_input()
self.screen.update(self.viewport.surface)
self.render()
pygame.quit()
sys.exit()
def pause():
paused = True
message_to_screen("Paused",black,-100,size="large")
message_to_screen("Press C to continue playing or Q to quit",black,25)
pygame.display.update()
while paused:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_c:
paused = False
elif event.key == pygame.K_q:
pygame.quit()
quit()
clock.tick(5)