Permalink
Browse files

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

  • Loading branch information...
1 parent 55b4894 commit 85ccf8208a60ea15153edc1838be0a35f58f4ad6 Katie Cunningham committed Mar 31, 2012
Showing with 29 additions and 6 deletions.
  1. +6 −3 roguey/classes/game.py
  2. +23 −3 roguey/classes/gamescreen.py
View
@@ -45,12 +45,15 @@ def __init__(self):
self.run()
def add_treasure(self, treasure):
+ ''' Adds the treasure to the player's inventory
+ '''
text = "You found a %s. %s" % (treasure.title, treasure.description)
self.inventory.add_to_inventory(treasure.title)
self.screen.draw_alert(text)
def move(self, hor, vert):
''' Moves the player, given a keypress.
+ Also evaluates if the player needs to fight or pick up some treasure.
'''
self.old_row, self.old_col = self.map.player
row = self.old_row + hor
@@ -77,11 +80,11 @@ def move(self, hor, vert):
self.screen.draw_inventory(self.inventory)
self.screen.draw_player(self.map.player)
self.screen.draw_screen_layers(self.map, self.player_stats)
- self.screen.draw_player(self.map.player)
- #self.screen.blit(self.player_blit, self.map.player)
- pygame.display.flip()
def end_game(self):
+ ''' The exit screen for when the player has died, or completed the game.
+ So far, all it does is exit the game.
+ '''
sys.exit()
def run(self):
@@ -5,6 +5,8 @@
class GameScreen(object):
def __init__(self):
+ ''' Does the initial drawing of the game screen.
+ '''
self.screen = pygame.display.set_mode((1280, 832))
self.font = pygame.font.SysFont(None, 48)
self.small_font = pygame.font.SysFont(None, 20)
@@ -14,11 +16,16 @@ def __init__(self):
self.inventory_screen = self.small_font.render("Inventory", True, WHITE, BLACK)
self.draw_alert("Welcome to Katie's Roguelike!")
self.stats_screen = self.small_font.render("ARGH", True, WHITE, BLACK)
+ pygame.display.flip()
- def draw_player(self, map):
- self.screen.blit(self.player_blit, map)
+ def draw_player(self, coord):
+ ''' Draws the player at a specific coordinate
+ '''
+ self.screen.blit(self.player_blit, coord)
def draw_stats(self, player_stats, color=WHITE):
+ ''' Renders the stats for the player
+ '''
self.screen.blit(self.stats_screen, (1008, 0))
self.stats_screen = self.small_font.render(player_stats.name, True, color, BLACK)
self.screen.blit(self.stats_screen, (1008, 0))
@@ -41,6 +48,8 @@ def draw_alert(self, alert, color=WHITE):
pygame.display.flip()
def draw_inventory(self, inventory):
+ ''' Renders the inventory for the user
+ '''
self.screen.blit(self.inventory_screen, (1008, 100))
items = inventory.get_items()
for i in range(items.__len__()):
@@ -50,7 +59,6 @@ def draw_inventory(self, inventory):
for item in items:
line = self.small_font.render(item, True, WHITE, BLACK)
self.screen.blit(line, (1008, (items.index(item)+1)*15+100))
- pygame.display.flip()
def draw_treasure(self, treasure_map):
''' Draws the treasure chests yet to be opened.
@@ -62,13 +70,17 @@ def draw_treasure(self, treasure_map):
self.screen.blit(treasure, (row*TILE_SIZE, col*TILE_SIZE))
def draw_monsters(self, map):
+ ''' Draws monsters that appear in the area that the rogue can see
+ '''
for row in range(ROWS):
for col in range(COLUMNS):
if map.monsters[row][col] != 0 and map.current[row][col] != 0:
monster = pygame.image.load(IMG_DIR + 'dumb_monster.png')
self.screen.blit(monster, (row*TILE_SIZE, col*TILE_SIZE))
def draw_walls(self, walls):
+ ''' Draws walls on the game map
+ '''
for row in range(ROWS):
for col in range(COLUMNS):
if walls[row][col] != 0:
@@ -91,17 +103,25 @@ def draw_darkness(self, map):
self.screen.blit(shadow, (row*TILE_SIZE, col*TILE_SIZE))
def draw_background(self):
+ ''' Draws my glorious background.
+ '''
self.screen.blit(self.bg, (0,0))
def draw_screen_layers(self, map, player_stats):
+ ''' Draws the layers of the game screen
+ '''
self.draw_background()
self.draw_treasure(map.treasure)
self.draw_walls(map.walls)
self.draw_monsters(map)
self.draw_darkness(map)
self.draw_stats(player_stats=player_stats)
+ self.draw_player(coord=map.player)
+ pygame.display.flip()
def animate_move(self, hor, vert, blit):
+ ''' This function is NOT USED. In theory, it animates a blit, but it makes everything look awful.
+ '''
if vert:
if vert > 0:
for i in range(TILE_SIZE/MOVEMENT_SIZE):

0 comments on commit 85ccf82

Please sign in to comment.