all repos — Legends-RPG @ 00a3f968654ae3c3bde4de50fa7c18bbe4190801

A fantasy mini-RPG built with Python and Pygame.

Added icons to item menu screen
Justin Armstrong justinmeister@gmail.com
Tue, 01 Apr 2014 22:15:37 -0700
commit

00a3f968654ae3c3bde4de50fa7c18bbe4190801

parent

41e31ec9b4428abcfcac1c9661c5addb5fdf9802

4 files changed, 54 insertions(+), 16 deletions(-)

jump to
M data/menugui.pydata/menugui.py

@@ -1,3 +1,4 @@

+# -*- coding: utf-8 -*- """ This class controls all the GUI for the player menu screen.

@@ -5,6 +6,7 @@ """

import pygame as pg from . import setup from . import constants as c +from . import tilemap class SmallArrow(pg.sprite.Sprite):

@@ -74,11 +76,16 @@ super(InfoBox, self).__init__()

self.inventory = inventory self.player_stats = player_stats self.font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 22) - self.title_font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 24) + self.big_font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 24) + self.title_font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 28) self.title_font.set_underline(True) - self.possible_items = ['Healing Potion', 'Chain Mail', - 'Wooden Shield', 'Long Sword', - 'Rapier'] + self.get_tile = tilemap.get_tile + self.sword = self.get_tile(96, 0, setup.GFX['shopsigns'], 32, 32) + self.shield = self.get_tile(64, 0, setup.GFX['shopsigns'], 32, 32) + self.potion = self.get_tile(32, 0, setup.GFX['shopsigns'], 32, 32) + self.possible_potions = ['Healing Potion'] + self.possible_armor = ['Wooden Shield', 'Chain Mail'] + self.possible_weapons = ['Long Sword', 'Rapier'] self.possible_magic = ['Fire Blast', 'Cure'] self.quantity_items = ['Healing Potion'] self.state_dict = self.make_state_dict()

@@ -117,24 +124,55 @@

def show_items(self): """Show list of items the player has""" title = 'ITEMS' - item_list = [] + potions = ['POTIONS'] + weapons = ['WEAPONS'] + armor = ['ARMOR'] for item in self.inventory: - if item in self.possible_items: - item_list.append(item) + if item in self.possible_potions: + potions.append(item) + elif item in self.possible_weapons: + weapons.append(item) + elif item in self.possible_armor: + armor.append(item) surface, rect = self.make_blank_info_box(title) + surface = self.blit_item_list(surface, weapons, 85) + surface = self.blit_item_list(surface, armor, 235) + surface = self.blit_item_list(surface, potions, 390) + + self.sword['rect'].topleft = 50, 80 + self.shield['rect'].topleft = 50, 230 + self.potion['rect'].topleft = 50, 385 + surface.blit(self.sword['surface'], self.sword['rect']) + surface.blit(self.shield['surface'], self.shield['rect']) + surface.blit(self.potion['surface'], self.potion['rect']) + + + self.image = surface + self.rect = rect + + + def blit_item_list(self, surface, item_list, starty): + """Blit item list to info box surface""" for i, item in enumerate(item_list): if item in self.quantity_items: text = item + ": " + str(self.inventory[item]['quantity']) + text_image = self.font.render(text, True, c.NEAR_BLACK) + text_rect = text_image.get_rect(x=90, y=starty+(i*50)) + surface.blit(text_image, text_rect) + elif i == 0: + text = item + text_image = self.big_font.render(text, True, c.NEAR_BLACK) + text_rect = text_image.get_rect(x=90, y=starty) + surface.blit(text_image, text_rect) else: text = item - text_image = self.font.render(text, True, c.NEAR_BLACK) - text_rect = text_image.get_rect(x=50, y=80+(i*50)) - surface.blit(text_image, text_rect) + text_image = self.font.render(text, True, c.NEAR_BLACK) + text_rect = text_image.get_rect(x=90, y=starty+(i*50)) + surface.blit(text_image, text_rect) - self.image = surface - self.rect = rect + return surface def show_magic(self):
M data/states/shop.pydata/states/shop.py

@@ -166,17 +166,17 @@ """Make list of items to be chosen"""

longsword_dialogue = 'Long Sword (100 gold)' rapier_dialogue = 'Rapier (50 gold)' - item = {'type': 'Long Sword', + item2 = {'type': 'Long Sword', 'price': 100, 'quantity': 1, 'dialogue': longsword_dialogue} - item2 = {'type': 'Rapier', + item1 = {'type': 'Rapier', 'price': 50, 'quantity': 1, 'dialogue': rapier_dialogue} - return [item, item2] + return [item1, item2] class ArmorShop(Shop):
M data/tools.pydata/tools.py

@@ -152,7 +152,7 @@

def create_game_data_dict(): """Create a dictionary of persistant values the player carries between states""" - player_items = {'gold': 100} + player_items = {'gold': 600} player_health = {'current': 100, 'maximum': 100}