In This program I want to have it register Pressed Keys But only once instead of multiple times. If you've played 2048, I am trying to make something like that. I want to do this without slowing the Frame rate.
import pygame, sys
pygame.init()
WIDTH, HEIGHT = 450,450
win = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
class Tile:
def __init__(self, x, y):
self.x = x
self.y = y
def Move(self):
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
print("Left")
elif keys[pygame.K_RIGHT]:
print("Right")
elif keys[pygame.K_UP]:
print("Up")
elif keys[pygame.K_DOWN]:
print("Down")
keys = pygame.key.get_pressed()
running = run = True
a = Tile(200, 500)
while run:
a.Move()
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
sys.exit()
pygame.display.update()