-
Notifications
You must be signed in to change notification settings - Fork 0
/
game001.py
29 lines (25 loc) · 1 KB
/
game001.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
import pygame # imports the pygame library into the program. Is a must have line of code
pygame.init() # initializes the pygame library. Is a must have line of code
# Set up the display
screen_width = 800 # sets the width of the screen in pixels
screen_height = 700 # sets the height of the screen in pixels
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Simple Pygame Program")
# Set up the font
font = pygame.font.SysFont("Arial", 48)
# Create the text
text = font.render("Digikids", True, (0, 5, 105))
# Get the text dimensions
text_width, text_height = font.size("Digikids")
# Set the text position
text_x = screen_width / 2
text_y = screen_height / 2
# Draw the text on the screen
screen.blit(text, (text_x, text_y)) # the blit function draws the text on the screen
# Update the screen
pygame.display.update()
# Wait for the user to close the window
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()