-
Notifications
You must be signed in to change notification settings - Fork 1
/
infoscreen.py
50 lines (34 loc) · 1.47 KB
/
infoscreen.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
"""
infoscreen.py
Contains the InfoScreen class, which is a state for the info screen
which shows lives and score before and after levels
"""
import pygame
from pygame.locals import *
from pygame.font import Font, get_default_font
from gamestate import GameState
import event_handlers
import options
class InfoScreen(GameState):
"""InfoScreen is a GameState which shows lives and score and waits for input
for input to start the next state
"""
def __init__(self, manager, score, lives, next_state):
GameState.__init__(self, manager)
sys_font = Font(get_default_font(), options.font_size)
self.score_text = sys_font.render(str(score), True, options.white)
self.lives_text = sys_font.render(str(lives), True, options.white)
self.next_state = next_state
def handle_events(self, events, keys):
return (event_handlers.check_quit(events, keys) and
event_handlers.check_shoot_button(events, keys, self.change_state))
def draw(self, screen):
right_edge = options.width * 2 / 3
score_height = options.height / 3
lives_height = score_height + options.height / 6
screen.blit(self.score_text,
self.score_text.get_rect(midright = (right_edge, score_height)))
screen.blit(self.lives_text,
self.lives_text.get_rect(midright = (right_edge, lives_height)))
def change_state(self):
self.manager.change_state(self.next_state)