Began player menu screen
Justin Armstrong justinmeister@gmail.com
Mon, 31 Mar 2014 16:50:21 -0700
6 files changed,
187 insertions(+),
2 deletions(-)
M
data/constants.py
→
data/constants.py
@@ -21,6 +21,8 @@ NEAR_BLACK = (1, 0, 0)
WHITE = (255, 255, 255) BLACK_BLUE = (19, 15, 48) NEAR_BLACK_BLUE = (20, 15, 48) +LIGHT_BLUE = (0, 153, 204) +DARK_RED = (118, 27, 12)
M
data/main.py
→
data/main.py
@@ -3,6 +3,7 @@ from data.states.town import town
from data.states.castle import castle from data.states import shop from data.states.house import house +from data.states import player_menu from . import setup, tools from . import constants as c@@ -16,6 +17,7 @@ ARMOR_SHOP = 'armor shop'
WEAPON_SHOP = 'weapon shop' MAGIC_SHOP = 'magic shop' POTION_SHOP = 'potion shop' +PLAYER_MENU = 'player menu' def main():@@ -29,7 +31,8 @@ INN: shop.Inn(),
ARMOR_SHOP: shop.ArmorShop(), WEAPON_SHOP: shop.WeaponShop(), MAGIC_SHOP: shop.MagicShop(), - POTION_SHOP: shop.PotionShop() + POTION_SHOP: shop.PotionShop(), + PLAYER_MENU: player_menu.Player_Menu() } run_it.setup_states(state_dict, c.MAIN_MENU)
M
data/states/level_state.py
→
data/states/level_state.py
@@ -28,6 +28,7 @@ self.game_data = game_data
print(game_data['player inventory']) self.current_time = current_time self.state = 'normal' + self.allow_input = False self.background = tm.create_map_layer1(self.name, self.map_width, self.map_height)@@ -74,6 +75,7 @@ self.player.update(keys, current_time)
self.sprites.update(current_time) self.collision_handler.update(keys, current_time) self.dialogue_handler.update(keys, current_time) + self.check_for_menu(keys) self.viewport_update() self.draw_level(surface)@@ -90,6 +92,20 @@ self.update_game_data()
self.done = True + def check_for_menu(self, keys): + """Check if player hits enter to go to menu""" + if keys[pg.K_RETURN] and self.allow_input: + if self.player.state == 'resting': + self.player.location = self.player.get_tile_location() + self.next = 'player menu' + self.update_game_data() + self.done = True + + + if not keys[pg.K_RETURN]: + self.allow_input = True + + def update_game_data(self): """Update the persistant game data dictionary""" self.game_data['last location'] = self.player.location@@ -105,7 +121,9 @@ location = copy.deepcopy(self.game_data['last location'])
direction = self.game_data['last direction'] state = self.game_data['last state'] - if direction == 'up': + if self.next == 'player menu': + pass + elif direction == 'up': location[1] += 1 elif direction == 'down': location[1] -= 1