-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
113 lines (95 loc) · 3.44 KB
/
views.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"""
Contains classes to control the view of each game, with methods to update
what is drawn on the game screen.
"""
import pygame
class DgView:
"""
View for the dress up game, contains functions for updating the display.
Attributes:
ARROWS: a list of strings for the images for the display arrows
BG_IMG: a pygame Surface representing the loaded background image
FG_IMG: a pygame Surface representing the loaded foreground image
instructions_img: a pygame Surface representing the loaded
instructions image, changes when start instructions are closed
"""
ARROWS = [
'sela_test_images/top_select.png',
'sela_test_images/mid_select.png',
'sela_test_images/bottom_select.png'
]
def __init__(self, game, player):
self._game = game
self._player = player
self.BG_IMG = pygame.image.load('sela_test_images/back_bg_layer.png')
self.FG_IMG = pygame.image.load('sela_test_images/front_bg_layer.png')
self.instructions_img = pygame.image.load(
'sela_test_images/instructions.png')
def draw_bg(self):
"""
Draw the background for the game in the pygame window.
"""
self._game.screen.blit(self.BG_IMG, (0, 0))
self._game.screen.blit(self.FG_IMG, (0, 0))
def draw_clothes(self):
"""
Draw the clothes the frog is wearing in the pygame window.
"""
for i in range(3):
self._game.screen.blit(self._player.images[i],
self._player.coords[i])
def draw_instructions(self):
"""
Display the correct instructions in the pygame window.
If the start instructions have been closed, switch to displaying
the instructions for continuing.
"""
if not self._game.show_instructions:
self.instructions_img = \
pygame.image.load('sela_test_images/enter_instruct.png')
self._game.screen.blit(self.instructions_img, (0, 0))
def draw_arrows(self):
"""
Display the highlighted arrow to show which article of clothing
is being changed.
"""
if not self._game.show_instructions:
self._game.screen.blit(pygame.image.load(
self.ARROWS[self._game.item]), (0, 0))
@staticmethod
def update():
"""
Update the display.
"""
pygame.display.update()
class FpView():
"""
View for the platformer, contains functions for updating the display.
"""
def __init__(self, game, player, platforms):
self._game = game
self._player = player
self._platforms = platforms
self.BG_IMG = pygame.image.load(
"assets/tree_background.png").convert_alpha()
def draw_bg(self):
"""
Draw the background for the game.
"""
self._game.screen.blit(self.BG_IMG, (0, 0))
def draw_player(self):
"""
Draw the player for the game.
"""
self._game.screen.blit(self._player.img, self._player.rect)
def draw_platforms(self):
"""
Draw the platforms for the game.
"""
self._platforms.group.draw(self._game.screen)
@staticmethod
def update():
"""
Update the display window.
"""
pygame.display.update()