Skip to content
This repository
Browse code

The last of the screen bits found. Lots of docstrings added.

  • Loading branch information...
commit 85ccf8208a60ea15153edc1838be0a35f58f4ad6 1 parent 55b4894
authored March 31, 2012
9  roguey/classes/game.py
@@ -45,12 +45,15 @@ def __init__(self):
45 45
         self.run()
46 46
 
47 47
     def add_treasure(self, treasure):
  48
+        ''' Adds the treasure to the player's inventory
  49
+        '''
48 50
         text = "You found a %s. %s" % (treasure.title, treasure.description)
49 51
         self.inventory.add_to_inventory(treasure.title)
50 52
         self.screen.draw_alert(text)
51 53
 
52 54
     def move(self, hor, vert):
53 55
         ''' Moves the player, given a keypress. 
  56
+            Also evaluates if the player needs to fight or pick up some treasure.
54 57
         '''
55 58
         self.old_row, self.old_col = self.map.player
56 59
         row = self.old_row + hor
@@ -77,11 +80,11 @@ def move(self, hor, vert):
77 80
             self.screen.draw_inventory(self.inventory)
78 81
         self.screen.draw_player(self.map.player)
79 82
         self.screen.draw_screen_layers(self.map, self.player_stats)
80  
-        self.screen.draw_player(self.map.player)
81  
-        #self.screen.blit(self.player_blit, self.map.player)
82  
-        pygame.display.flip()
83 83
 
84 84
     def end_game(self):
  85
+        ''' The exit screen for when the player has died, or completed the game. 
  86
+            So far, all it does is exit the game.
  87
+        '''
85 88
         sys.exit()
86 89
 
87 90
     def run(self):
26  roguey/classes/gamescreen.py
@@ -5,6 +5,8 @@
5 5
 class GameScreen(object):
6 6
     
7 7
     def __init__(self):
  8
+        ''' Does the initial drawing of the game screen.
  9
+        '''
8 10
         self.screen = pygame.display.set_mode((1280, 832))
9 11
         self.font = pygame.font.SysFont(None, 48)
10 12
         self.small_font = pygame.font.SysFont(None, 20)
@@ -14,11 +16,16 @@ def __init__(self):
14 16
         self.inventory_screen = self.small_font.render("Inventory", True, WHITE, BLACK)
15 17
         self.draw_alert("Welcome to Katie's Roguelike!")
16 18
         self.stats_screen = self.small_font.render("ARGH", True, WHITE, BLACK)
  19
+        pygame.display.flip()
17 20
 
18  
-    def draw_player(self, map):
19  
-        self.screen.blit(self.player_blit, map)
  21
+    def draw_player(self, coord):
  22
+        ''' Draws the player at a specific coordinate
  23
+        '''
  24
+        self.screen.blit(self.player_blit, coord)
20 25
 
21 26
     def draw_stats(self, player_stats, color=WHITE):
  27
+        ''' Renders the stats for the player
  28
+        '''
22 29
         self.screen.blit(self.stats_screen, (1008, 0))
23 30
         self.stats_screen = self.small_font.render(player_stats.name, True, color, BLACK)
24 31
         self.screen.blit(self.stats_screen, (1008, 0))
@@ -41,6 +48,8 @@ def draw_alert(self, alert, color=WHITE):
41 48
         pygame.display.flip()
42 49
 
43 50
     def draw_inventory(self, inventory):
  51
+        ''' Renders the inventory for the user
  52
+        '''
44 53
         self.screen.blit(self.inventory_screen, (1008, 100))
45 54
         items = inventory.get_items()
46 55
         for i in range(items.__len__()):
@@ -50,7 +59,6 @@ def draw_inventory(self, inventory):
50 59
         for item in items:
51 60
             line = self.small_font.render(item, True, WHITE, BLACK)
52 61
             self.screen.blit(line, (1008, (items.index(item)+1)*15+100))
53  
-        pygame.display.flip()
54 62
 
55 63
     def draw_treasure(self, treasure_map):
56 64
         ''' Draws the treasure chests yet to be opened.
@@ -62,6 +70,8 @@ def draw_treasure(self, treasure_map):
62 70
                     self.screen.blit(treasure, (row*TILE_SIZE, col*TILE_SIZE))
63 71
     
64 72
     def draw_monsters(self, map):
  73
+        ''' Draws monsters that appear in the area that the rogue can see
  74
+        '''
65 75
         for row in range(ROWS):
66 76
             for col in range(COLUMNS):
67 77
                 if map.monsters[row][col] != 0 and map.current[row][col] != 0:
@@ -69,6 +79,8 @@ def draw_monsters(self, map):
69 79
                     self.screen.blit(monster, (row*TILE_SIZE, col*TILE_SIZE))
70 80
     
71 81
     def draw_walls(self, walls):
  82
+        ''' Draws walls on the game map
  83
+        '''
72 84
         for row in range(ROWS):
73 85
             for col in range(COLUMNS):
74 86
                 if walls[row][col] != 0:
@@ -91,17 +103,25 @@ def draw_darkness(self, map):
91 103
                         self.screen.blit(shadow, (row*TILE_SIZE, col*TILE_SIZE))
92 104
 
93 105
     def draw_background(self):
  106
+        ''' Draws my glorious background.
  107
+        '''
94 108
         self.screen.blit(self.bg, (0,0))
95 109
 
96 110
     def draw_screen_layers(self, map, player_stats):
  111
+        ''' Draws the layers of the game screen
  112
+        '''
97 113
         self.draw_background()
98 114
         self.draw_treasure(map.treasure)
99 115
         self.draw_walls(map.walls)
100 116
         self.draw_monsters(map)
101 117
         self.draw_darkness(map)
102 118
         self.draw_stats(player_stats=player_stats)
  119
+        self.draw_player(coord=map.player)
  120
+        pygame.display.flip()
103 121
 
104 122
     def animate_move(self, hor, vert, blit):
  123
+        ''' This function is NOT USED. In theory, it animates a blit, but it makes everything look awful.
  124
+        '''
105 125
         if vert:
106 126
             if vert > 0:
107 127
                 for i in range(TILE_SIZE/MOVEMENT_SIZE):

0 notes on commit 85ccf82

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