-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.py
64 lines (46 loc) · 1.69 KB
/
stats.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
import pygame
pygame.init()
myfont = pygame.font.SysFont("monospace", 16)
black = 0, 0, 0
white = 255, 255, 255
def update_score(score, counter=1):
return score + counter
def update_life(life, counter=1):
return life + counter
def render_score(screen, score):
x = screen.get_size()[0]
text = myfont.render('Score: {}'.format(score), 1, black)
screen.blit(text, ((x / 3), 10))
def render_life(screen, life):
string = 'Life: {}'.format(life)
x = screen.get_size()[0]
text = myfont.render(string, 1, black)
screen.blit(text, ((x / 2), 10))
def render_time(screen, time):
string = 'Time: {}'.format(time)
x = screen.get_size()[0]
text = myfont.render(string, 1, black)
screen.blit(text, ((x / 1.5), 10))
def show_endgame(screen, time):
screen.fill(white)
myfont = pygame.font.SysFont("monospace", 25)
x, y = screen.get_size()
text = myfont.render("Congrats You finished the game in", 1, black)
screen.blit(text, ((x / 12), (y / 2)))
text = myfont.render("{} second/s".format(time), 1, black)
screen.blit(text, ((x / 2.5), (y / 1.5)))
def show_to_hit(screen, group):
x = screen.get_size()[0]
text = myfont.render('Hit: ', 1, black)
screen.blit(text, (0, 10))
group.draw(screen)
def game_over(screen):
screen.fill(white)
myfont = pygame.font.SysFont("monospace", 25)
x, y = screen.get_size()
text = myfont.render("Game Over", 1, black)
screen.blit(text, ((x / 2.5), (y / 2)))
text = myfont.render("\"The best way to find happiness", 1, black)
screen.blit(text, ((x / 6), (y / 1.5)))
text = myfont.render("is to stop looking so hard\"", 1, black)
screen.blit(text, ((x / 3), (y / 1.3)))