-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (32 loc) · 1.35 KB
/
main.py
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
39
40
41
42
43
44
45
46
47
import pygame
# Initialize Pygame
pygame.init()
# Constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
# Load the background image
background = pygame.image.load('assets/background.jpeg')
# Set up the display
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT: # Check if the user has clicked the close button
run = False
if event.type == pygame.KEYDOWN:
print(f"Key released: {event.unicode}") # event.key is gives out the ASCII value of the key
if event.type == pygame.KEYUP: # Check if the user has released a key
print("Key released")
if event.type == pygame.MOUSEBUTTONDOWN: # Check if the user has clicked the mouse
print(f'Mouse pressed: {event.button}')
if event.type == pygame.MOUSEBUTTONUP: # Check if the user has released the mouse
print("Mouse released")
if event.type == pygame.MOUSEMOTION: # Check if the user has moved the mouse
print(f"Mouse moved: {event.pos}")
if event.type == pygame.MOUSEWHEEL: # Check if the user has scrolled the mouse wheel
print(f"Mouse wheel: {event.y}")
# Blit the background image
screen.blit(background, (0, 0))
# Update the display
pygame.display.flip()
pygame.quit()