-
Notifications
You must be signed in to change notification settings - Fork 4
/
intro.py
46 lines (37 loc) · 1.32 KB
/
intro.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
try:
import pygame
import sys
except ImportError as err:
print("couldn't load module, %s" % (err))
sys.exit(2)
class Intro:
"""This will probably be adjusted to be usable for any text screen
but for now I will use it just for the intro / instructions screen"""
running = True
def __init__(self):
self.title = "PyDF"
self.textcolor = (255, 255, 255)
if not pygame.font.get_init():
pygame.font.init()
self.arialFnt = pygame.font.SysFont("Arial", 16)
def drawText(self, text, surface, x, y):
textobj = self.arialFnt.render(text, 1, self.textcolor)
textrect = textobj.get_rect()
textrect.topleft = (x, y)
surface.blit(textobj, textrect)
def waitForKey(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE: # pressing escape quits
self.running = False
return
if __name__ == "__main__":
pygame.init()
screen = pygame.display.set_mode((640, 480), pygame.RESIZABLE)
intro = Intro()
intro.drawText("hi", screen, 10, 10)
pygame.display.update()
intro.waitForKey()