Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactoring GameScreen's constructor.

  • Loading branch information...
commit 577b420a3dadb11719c22117b56e2e98de97c482 1 parent 5e0957e
Al Sweigart authored August 09, 2012

Showing 1 changed file with 7 additions and 10 deletions. Show diff stats Hide diff stats

  1. 17  square-shooter/square-shooter_makeover.py
17  square-shooter/square-shooter_makeover.py
@@ -35,8 +35,8 @@
35 35
 WINDOW_WIDTH = 640
36 36
 WINDOW_HEIGHT = 480
37 37
 
38  
-MAP_WIDTH = 480
39  
-MAP_HEIGHT = 480
  38
+MAP_WIDTH = WINDOW_WIDTH - 160
  39
+MAP_HEIGHT = WINDOW_HEIGHT
40 40
 
41 41
 MAP_SIZE = max(MAP_WIDTH, MAP_HEIGHT)
42 42
 
@@ -418,20 +418,17 @@ def __init__(self, world, screen):
418 418
         self.world = world
419 419
 
420 420
         self.screen = screen
421  
-        self.width, self.height = screen.get_size()
422  
-        self.bglayer = pygame.Surface(screen.get_size())
  421
+        self.bglayer = pygame.Surface((WINDOW_WIDTH, WINDOW_HEIGHT))
423 422
 
424 423
         font_name = pygame.font.get_default_font()
425 424
         self.hud_font =    pygame.font.SysFont(
426  
-            font_name, self.height / 10)
  425
+            font_name, WINDOW_HEIGHT / 10)
427 426
         self.msg_font = pygame.font.SysFont(
428  
-            font_name, self.height / 20)
429  
-
430  
-
  427
+            font_name, WINDOW_HEIGHT / 20)
431 428
 
432 429
         self.game_paused = False
433 430
 
434  
-        self.render_backround()
  431
+        self.render_background()
435 432
 
436 433
     def render(self):
437 434
         m = self.world
@@ -460,7 +457,7 @@ def render(self):
460 457
 
461 458
         pygame.display.flip()
462 459
 
463  
-    def render_backround(self):
  460
+    def render_background(self):
464 461
         self.bglayer.fill(BLACK)
465 462
         self.bglayer.fill(GREEN, (MAP_WIDTH, 0, WINDOW_WIDTH - MAP_WIDTH, MAP_HEIGHT))
466 463
 

0 notes on commit 577b420

Please sign in to comment.
Something went wrong with that request. Please try again.