-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeGame.py
More file actions
54 lines (48 loc) · 1.72 KB
/
theGame.py
File metadata and controls
54 lines (48 loc) · 1.72 KB
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
import pygame
from racingGame import racingGame
from main import game
import snake_game
# race = racingGame()
# race.playGame()
pygame.init()
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (61, 191, 52)
GRAY = (148, 148, 148)
DARKGRAY = (87, 87, 87)
width = 700
height = 700
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Break Time!")
play = True
clock = pygame.time.Clock()
display_surface = pygame.display.set_mode((width, height)) #display surface object for text
def show_text(text, fontsize, textColour, xPos, yPos): #background will be none
#displaying text
font = pygame.font.Font('freesansbold.ttf', fontsize) #set font
textSurf = font.render(text, True, textColour) #text surface object for test
textSurf = font.render(text, True, textColour) #text surface object for test
textRect = textSurf.get_rect() #rect obj for surface
textRect.center = (xPos, yPos) # set the center placement for obj
display_surface.blit(textSurf, textRect)
while play:
width = 700
height = 700
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Break Time!")
for event in pygame.event.get():
if event.type == pygame.QUIT:
play = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
snake_game.main()
elif event.key == pygame.K_r:
game()
screen.fill((200,150,150))
show_text('Congrats!', 32, BLACK, width/2, height/2-100)
show_text('You finished 20 minutes of hard work', 32, BLACK, width/2, height/2-50)
show_text('Which game would you like to play?', 32, BLACK, width/2, height/2)
show_text('S for Snake or R for Racing?', 32, BLACK, width/2, height/2+50)
pygame.display.flip()
clock.tick(60)
pygame.quit()