forked from sd18fall/BrickBreakerMVC
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview.py
More file actions
33 lines (29 loc) · 1.25 KB
/
view.py
File metadata and controls
33 lines (29 loc) · 1.25 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
"""
BrickBreaker view code
"""
import pygame
class PyGameWindowView(object):
""" A view of brick breaker rendered in a Pygame window """
def __init__(self, model, size):
""" Initialize the view with a reference to the model and the
specified game screen dimensions (represented as a tuple
containing the width and height """
self.model = model
self.screen = pygame.display.set_mode(size)
def draw(self):
""" Draw the current game state to the screen """
self.screen.fill(pygame.Color(0,0,0))
for brick in self.model.bricks:
pygame.draw.rect(self.screen,
pygame.Color(255, 255, 255),
pygame.Rect(brick.x,
brick.y,
brick.width,
brick.height))
pygame.draw.rect(self.screen,
pygame.Color(255, 0, 0),
pygame.Rect(self.model.paddle.x,
self.model.paddle.y,
self.model.paddle.width,
self.model.paddle.height))
pygame.display.update()