-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartscreen.py
67 lines (51 loc) · 2.32 KB
/
startscreen.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#Ali
import pygame
pygame.init()
white = (255, 255, 255) #assigns rgb color values to variables
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 155, 0)
display_width = 800 #sets the screen width
display_height = 800 #sets the screen height
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('Dungeon Explorer') #Title on the title bar of the screen
clock = pygame.time.Clock()
font = pygame.font.SysFont(None, 25) #sets the font
def text_objects(text,color,size): #function for diffeent font sizes used
if size == "small":
textSurface = smallfont.render(text,True,color)
elif size == "medium":
textSurface = medfont.render(text, True, color)
elif size == "large":
textSurface = largefont.render(text, True, color)
return textSurface, textSurface.get_rect()
def text(msg, color, y_displace=0, size = "small"): #function for the text on the screen
textSurf, textRect = text_objects(msg,color,size)
textRect.center = (display_width / 2), (display_height / 2)+y_displace
gameDisplay.blit(textSurf, textRect)
smallfont = pygame.font.SysFont("comicsansms", 25)
medfont = pygame.font.SysFont("comicsansms", 50)
largefont = pygame.font.SysFont("comicsansms", 80)
def game_intro(): #while game intro is on this is what's going happen
intro = True
while intro:
# checks for events
for event in pygame.event.get(): #if someclicks X on top right corner of screen then exit
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_c: #if someone presses "c" start game
intro = False
if event.key == pygame.K_q: # if q is pressed then exit out of game
pygame.quit()
quit()
gameDisplay.fill(white) # background color is white
text("Dungeon Explorer", green, -100, "medium") #messages to user on the start screen
text("Game's Objective", black, -30)
text("Description", black, 10)
text("Description", black, 50)
text("Press C to Play or Q to Quit", black, 180) # instructions to start or end the game
pygame.display.update() # updates the screen
clock.tick(15) # fps of 15
game_intro()