Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pygame.locals import *
- import pygame
- import sys
- import os
- def KEY_PRESSED():
- for Event in pygame.event.get():
- if Event.type == pygame.KEYDOWN:
- if Event.key == K_LEFT or Event.key == K_a:
- return "LEFT"
- if Event.key == K_RIGHT or Event.key == K_d:
- return "RIGHT"
- if Event.key == K_DOWN or Event.key == K_s:
- return "DOWN"
- if Event.key == K_UP or Event.key == K_w:
- return "UP"
- if Event.key == K_TAB:
- return "TAB"
- if Event.key == K_ESCAPE:
- return "QUIT"
- if Event.key == K_SPACE:
- return "SPACE"
- if Event.type == pygame.QUIT:
- return "QUIT"
- return None
- GAME_LOOP = True
- pygame.init() # Starting PyGame library.
- WIN = pygame.display.set_mode((1280, 720)) # Creating screen.
- while GAME_LOOP:
- if KEY_PRESSED() == 'QUIT':
- MAIN_LOOP = False
- pygame.quit()
- sys.exit()
- if KEY_PRESSED() == 'TAB':
- print('Tab')
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement