-
Notifications
You must be signed in to change notification settings - Fork 0
/
animate_words.py
32 lines (26 loc) · 1.09 KB
/
animate_words.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
from variables import *
def display_text_animation(string, y_var):
# Display text animation on the screen
text = ''
for i in range(len(string)):
# Fill the screen with the background color
SCREEN.fill(DARK_GREY)
# Add the next character to the text and create a text surface
text += string[i]
text_surface = instruction_font.render(text, True, WHITE)
# Set the position of the text surface and display it on the screen
text_rect = text_surface.get_rect()
text_rect.midleft = (40, BASE_OFFSET_Y - 165 + 45 * (y_var-1))
SCREEN.blit(text_surface, text_rect)
pygame.display.update()
# Pause for a short period of time
pygame.time.wait(70)
# Handle keyboard events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()