-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_2.py
More file actions
38 lines (28 loc) · 826 Bytes
/
test_2.py
File metadata and controls
38 lines (28 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pygame
# Initialize Pygame
pygame.init()
# Set up the window
screen_width, screen_height = 640, 480
screen = pygame.display.set_mode((screen_width, screen_height))
# Set up the clock
clock = pygame.time.Clock()
fps = 33
# Set up the key flag
key_pressed = False
# Game loop
while True:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
elif event.type == pygame.KEYDOWN:
# Ignore key presses if a key is already pressed
if not key_pressed:
key_pressed = True
# Handle the key press here
elif event.type == pygame.KEYUP:
key_pressed = False
# Update the game state here
# Draw the screen here
# Limit the frame rate
print(clock.tick(fps))