Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring GameScreen's constructor.

  • Loading branch information...
commit 577b420a3dadb11719c22117b56e2e98de97c482 1 parent 5e0957e
Al Sweigart authored
Showing with 7 additions and 10 deletions.
  1. +7 −10 square-shooter/square-shooter_makeover.py
17 square-shooter/square-shooter_makeover.py
View
@@ -35,8 +35,8 @@
WINDOW_WIDTH = 640
WINDOW_HEIGHT = 480
-MAP_WIDTH = 480
-MAP_HEIGHT = 480
+MAP_WIDTH = WINDOW_WIDTH - 160
+MAP_HEIGHT = WINDOW_HEIGHT
MAP_SIZE = max(MAP_WIDTH, MAP_HEIGHT)
@@ -418,20 +418,17 @@ def __init__(self, world, screen):
self.world = world
self.screen = screen
- self.width, self.height = screen.get_size()
- self.bglayer = pygame.Surface(screen.get_size())
+ self.bglayer = pygame.Surface((WINDOW_WIDTH, WINDOW_HEIGHT))
font_name = pygame.font.get_default_font()
self.hud_font = pygame.font.SysFont(
- font_name, self.height / 10)
+ font_name, WINDOW_HEIGHT / 10)
self.msg_font = pygame.font.SysFont(
- font_name, self.height / 20)
-
-
+ font_name, WINDOW_HEIGHT / 20)
self.game_paused = False
- self.render_backround()
+ self.render_background()
def render(self):
m = self.world
@@ -460,7 +457,7 @@ def render(self):
pygame.display.flip()
- def render_backround(self):
+ def render_background(self):
self.bglayer.fill(BLACK)
self.bglayer.fill(GREEN, (MAP_WIDTH, 0, WINDOW_WIDTH - MAP_WIDTH, MAP_HEIGHT))
Please sign in to comment.
Something went wrong with that request. Please try again.