def get_game_variables(game): player = game.temp_player entities = [player] game_map = GameMap(game.width, game.height, game.tile_size) game_map.make_map(game.max_room, game.room_min_size, game.room_max_size, player, entities) message_log = MessageLog(game.message_x, game.message_width, game.message_height) game_state = GameState.PLAYERS_TURN return player, entities, game_map, message_log, game_state,
def main(): screen_width = 80 screen_height = 50 map_width = 80 map_height = 45 colors = { 'dark_wall': libtcod.Color(0, 0, 100), 'dark_ground': libtcod.Color(50, 50, 150) } player = Entity(int(screen_width / 2), int(screen_height / 2), '@', libtcod.white) npc = Entity(int(screen_width / 2 - 5), int(screen_height / 2), '@', libtcod.yellow) entities = [npc, player] libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(screen_width, screen_height, 'libtcod tutorial revised', False) con = libtcod.console_new(screen_width, screen_height) key = libtcod.Key() mouse = libtcod.Mouse() game_map = GameMap(map_width, map_height) while not libtcod.console_is_window_closed(): libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse) render_all(con, entities, game_map, screen_width, screen_height, colors) libtcod.console_flush() clear_all(con, entities) action = handle_keys(key) move = action.get('move') exit = action.get('exit') fullscreen = action.get('fullscreen') if move: dx, dy = move if not game_map.is_blocked(player.x + dx, player.y + dy): player.move(dx, dy) if exit: return True if fullscreen: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) return True
def __init__(self, width, height, x, y, constants, player): self.maps = [[None for x in range(width)] for y in range(height)] self.x = x self.y = y game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_buildings'], constants['building_min_size'], constants['building_max_size'], constants['map_width'], constants['map_height'], player, game_map.entities, constants['max_enemies'], constants['max_items_per_building']) self.maps[x][y] = game_map
def enter_nameless_location(self, map_creator): player = self.engine.entities.player self.engine.world_map.current_dungeon_entry_point = (player.x, player.y) game_map = GameMap(map_vars.width, map_vars.height, map_creator=map_creator) game_map.make_map(self.engine.entities) self.engine.world_map.current_dungeon = game_map self.engine.player_location = PlayerLocations.DUNGEON self.engine.regulatory_flags.add('change_location')
def get_game_variables(constants): fighter_component = Fighter(hp=1250, defense=10, power=40) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, 197, libtcod.Color(15, 77, 0), 'Wrpgnyth', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.TENTACLE, power_bonus=20) tentaclaws = Entity(0, 0, 218, libtcod.red, 'Tentaclaws', equippable=equippable_component) player.inventory.add_item(tentaclaws) player.equipment.toggle_equip(tentaclaws) equippable_component = Equippable(EquipmentSlots.TENTACLE, power_bonus=20, defense_bonus=20) aluminitetentasleeve = Entity(0, 0, 192, libtcod.silver, 'Aluminite Tentasleeve', equippable=equippable_component) player.inventory.add_item(aluminitetentasleeve) player.equipment.toggle_equip(aluminitetentasleeve) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) equipment_component = Equipment() level_component = Level() player = Entity(0, 0, tiles.get('player_tile'), libtcod.white, 'you', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) #godmode equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=800, defense_bonus=800) dagger = Entity(0, 0, tiles.get('dagger_tile'), libtcod.white, 'Dagger', render_order=RenderOrder.ITEM, equippable=equippable_component, sprite_main_shift=320) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) item_component = Item(use_function=heal, amount=40) potion = Entity(0, 0, tiles.get('healingpotion_tile'), libtcod.white, 'Healing Potion', render_order=RenderOrder.ITEM, item=item_component) player.inventory.add_item(potion) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=3, speed=100) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity( [], 0, 0, "@", libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, ) entities = [player] dagger = items["dagger"] player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants["map_width"], constants["map_height"]) game_map.make_map( constants["max_rooms"], constants["room_min_size"], constants["room_max_size"], constants["map_width"], constants["map_height"], player, entities, ) camera = Camera( 0, 0, constants["screen_width"], constants["screen_height"], constants["map_width"], constants["map_height"], ) message_log = MessageLog( constants["message_x"], constants["message_width"], constants["message_height"], constants["screen_height"] ) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state, camera
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=12, strength=6, agility=6, intelligence=6, charisma=4, perception=4, endurance=4) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', constants['colors'].white(), 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, damage_dice_count=1, damage_die_face=4, damage_bonus=0, weapon_type='melee', damage_type='piercing') dagger = Entity(0, 0, '-', constants['colors'].lblue(), 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def generate_location(self): location_choice = random_choice_from_dict(weight_factor( self.locations)) location = self.locations[location_choice] location_type = random_choice_from_dict(location['types']) if location_choice == 'city': name = 'Remains of {0} of the city of {1}'.format( location_type, choice(location['names'])) elif location_choice == 'cave': name = '{0} of {1}'.format(location_type, choice(location['names'])).strip() landmark = Landmark(name, location_choice, location_type) return GameMap(map_vars.width, map_vars.height, map_creator=CaveMap(landmark=landmark)) landmark = Landmark(name, location_choice, location_type) location = GameMap(map_vars.width, map_vars.height, map_creator=DungeonMap(10, 3, 5, landmark=landmark)) return location
def generate_location(self): location_choice = random_choice_from_dict(weight_factor(self.locations)) location = self.locations[location_choice] location_type = random_choice_from_dict(location['types']) if location_choice == 'temple': name = '{0} of the {1}'.format(location_type, choice(location['names'])) elif location_choice == 'settlement': name = '{0} {1} {2}'.format(choice(location['first_names']), choice(location['last_names']), location_type).strip() landmark = self.generate_landmark(name, location_choice, location_type) location = GameMap(map_vars.width, map_vars.height, map_creator=ForestMap(5, landmark=landmark)) return location
def move_to(self, x, y, constants, player): self.x = x self.y = y if not self.maps[x][y]: game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map( constants['max_buildings'], constants['building_min_size'], constants['building_max_size'], constants['map_width'], constants['map_height'], player, game_map.entities, constants['max_enemies'], constants['max_items_per_building']) self.maps[x][y] = game_map else: self.maps[x][y].entities.append(player)
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2, magic=0) inventory_component = Inventory(26) equipment_inventory_component = Equipment_Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, equipment_inventory=equipment_inventory_component) entities = [player] equipment_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=1) dagger = Entity(0, 0, '-', libtcod.darker_orange, "Dagger", equippable=equipment_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) item_component = Item(use_function=cast_magic, damage=2, maximum_range=3) magic_wand = Entity(0, 0, '|', libtcod.darker_sepia, "Magic Wand", item=item_component) player.inventory.add_item(magic_wand) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): ''' Initializes game variables ''' # creates player if DEBUG == 1: fighter_component = Fighter(hp=1000, defense=1, power=20) else: fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] # starting weapon equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) cashable_component = Cashable(10) dagger = Entity(0, 0, '/', libtcod.orange, 'Rusty Dagger (+2A)', equippable=equippable_component, cashable=cashable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # initialize game game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants, player): entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def __init__(self): self.map_width = 80 self.map_height = 45 self.game_map = GameMap(self.map_width, self.map_height) self.player = Hero(int(self.map_width / 2), int(self.map_height / 2), '@', 'player') self.entities = [self.player] self.entities.append( Entity(int(self.map_width / 2 - 5), int(self.map_height / 2), '@', 'npc')) self.current_entity = 0 self.energy_threshold = 5
def get_game_variables(constants, name_character): player = new_player(name_character, constants['colors']) entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(player, entities, constants['colors']) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYER_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(roll_character_attributes(), current_hp=100, base_armor_class=10, base_armor=10, base_cth_modifier=3, base_speed=100, base_attack_cost=100, base_movement_cost=100, base_natural_hp_regeneration_speed=50, base_damage_dice={ "physical": [[1, 3]], "fire": [], "ice": [], "lightning": [], "holy": [], "chaos": [], "arcane": [], "poison": [], }) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, 0x1004, "white", 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, equipment=equipment_component, level=level_component) entities = [player] message_log = MessageLog(constants["message_x"], constants["message_width"], constants["message_height"]) game_map: GameMap = GameMap(width=constants["map_width"], height=constants["map_height"]) game_map.make_map(constants["max_rooms"], constants["room_min_size"], constants["room_max_size"], constants["map_width"], constants["map_height"], player, entities) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(config): level_component = Level(current_level=0, current_xp=0, level_up_base=2, level_up_factor=3, level_up_exponent=2) player = Entity(0, 0, ' ', libtcod.white, 'Ghost', blocks=True, render_order=RenderOrder.GHOST, level=level_component) entities = [player] game_map = GameMap(config) game_map.make_map(player, entities) message_log = MessageLog(config) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def initialize_cave(self, width: int, height: int): game_map = GameMap(width=width, height=height) game_map.walkable[:] = True game_map.transparent[:] = True for i in range(height): for j in range(width): point = Point(x=j, y=i) if i == 0 or j == 0 or i == height - 1 or j == width - 1: game_map.place_tile(point, Tile.cave(point=point)) if random.random() < INITIAL_CHANCE: game_map.place_tile(point, Tile.cave(point=point)) self.game_map = game_map
def get_game_variables(constants): if constants['dev_mode'] == 1: fighter_component = Fighter(hp=999, defense=999, power=999) else: fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player_f_name = get_generic_first_name() player_l_name = get_generic_last_name() player = Entity(0, 0, '@', libtcod.white, player_f_name, player_l_name, blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component, is_pc=True) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def play(self): libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Moria - {0}'.format(self.iteration), False, libtcod.RENDERER_SDL2, "F", False) self.root_console = libtcodconsole.Console(SCREEN_WIDTH, SCREEN_HEIGHT) self.panel = libtcodconsole.Console(SCREEN_WIDTH, PANEL_HEIGHT) fighter_component = Fighter(hp=PLAYER_MAX_HEALTH, defence=PLAYER_DEFENCE, power=PLAYER_POWER) inventory_component = Inventory(26) equipment_component = Equipment() coin_pouch = CoinPouch(0) self.player = Entity(0, 0, '@', libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, equipment=equipment_component, coin_pouch=coin_pouch) self.entities = [self.player] self.game_map = GameMap() self.game_map.make_map(self.player, self.entities) self.fov_recompute = True self.fov_map = initialize_fov(self.game_map) self.message_log = MessageLog() self.game_state = GameStates.PLAYERS_TURN self.previous_game_state = self.game_state self.init_game() while not self.game_ended and self.player is not None: if self.agent is not None: print("Shop has", len(self.game_map.shop.items)) self.agent.action = None self.run_agent(self.player, self.agent, self.fov_map) self.current_enemy = None self.run_game() return self.game_result
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(20) level_component = Level() equipment_component = Equipment() player = Entity(int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), '@', tcod.red, 'Player', blocks=True, fighter=fighter_component, render_order=RenderOrder.ACTOR, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', tcod.sky, 'Rusty Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map( constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, ) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYER_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): # Creates the player's components. fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() # Creates the player object. player = Entity(0, 0, "@", libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) # Creates a list of initial static entities. entities = [player] # Gives the player a starting weapon. equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, "-", libtcod.sky, "Dagger", equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # Creates the game map and calls its make_map function. game_map = GameMap(constants["map_width"], constants["map_height"]) game_map.make_map(constants["max_rooms"], constants["room_min_size"], constants["room_max_size"], constants["map_width"], constants["map_height"], player, entities) # Creates the message log that will store text messages. message_log = MessageLog(constants["message_x"], constants["message_width"], constants["message_height"]) # Stores the current game state integer value, e.g. PLAYERS_TURN is 1. game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants: Dict) -> Tuple: # initialize player/fighter and inventory fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(int(constants['screen_width'] / 2), int(constants['screen_height'] / 2), "@", constants['colors'].get('player'), 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] # set up inventory stuff equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', tcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # initialize game map game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, constants['colors']) # initialize blank message log message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) # set initial game state game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): # Components fighter_component = Fighter(hp=100, defense=2, power=5) inventory_component = Inventory(26) level_component = Level() equipement_component = Equipement() # Entities player = Entity(int(constants['screen_width'] / 2) - 10, int(constants['screen_height'] / 2), "Player", "@", libtcod.white, fighter=fighter_component, ai=None, inventory=inventory_component, level=level_component, equipement=equipement_component, render_order=RenderOrder.ACTOR) entities = [player] # Give player equipement starter pack equippable_component = Equippable(EquipementSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, 'Dagger', '-', libtcod.sky, equippable=equippable_component) player.inventory.add_item(dagger) player.equipement.toggle_equip(dagger) game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['room_min_size'], constants['room_max_size'], constants['max_rooms'], constants['map_width'], constants['map_height'], player, entities) # Message Log init message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) # Game State game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def get_game_variables(constants): fighter_component = Fighter(hp=30, defense=2, power=5) inventory_component = Inventory(26) player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component) entities = [player] game_map = GameMap(constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities, constants['max_monsters_per_room'], constants['max_items_per_room']) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def main(): screen_width = 80 screen_height = 50 map_width = 80 map_height = 45 room_max_size = 10 room_min_size = 6 max_rooms = 30 colors = { 'dark_wall': libtcod.Color(0, 0, 100), 'dark_ground': libtcod.Color(50, 50, 150) } player = Entity(int(screen_width / 2), int(screen_height / 2), '@', libtcod.white) npc = Entity(int(screen_width / 2), int(screen_height / 2), '%', libtcod.red) entities = [npc, player] libtcod.console_set_custom_font( 'arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(screen_width, screen_height, 'Roguelike', False) console = libtcod.console_new(screen_width, screen_height) game_map = GameMap(map_width, map_height) game_map.make_map(max_rooms, room_min_size, room_max_size, map_width, map_height, player) key = libtcod.Key() mouse = libtcod.Mouse() while not libtcod.console_is_window_closed(): libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse) render_all(console, entities, game_map, screen_width, screen_height, colors) libtcod.console_flush() clear_all(console, entities) action = handle_keys(key) move = action.get('move') exit = action.get('exit') fullscreen = action.get('fullscreen') if move: movement_x, movement_y = move if not game_map.is_blocked(player.x + movement_x, player.y + movement_y): player.move(movement_x, movement_y) if exit: return True if fullscreen: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
def get_game_variables(constants): fighter_component = Fighter(hp=100, defense=1, power=2) social_component = Social(bond=0) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '<', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) game_map = GameMap(constants['map_x'], constants['map_width'], constants['map_height']) #game_map = GameMap(constants['map_x'],constants['map_width'], constants['map_height']) game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities) message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height']) #hud = HUD() game_state = GameStates.PLAYERS_TURN return player, entities, game_map, message_log, game_state
def neighbor_map() -> GameMap: game_map: GameMap = GameMap(width=20, height=11) """ 01234567890123456789 .XXX.X...XXX.....XXX XX.XX..X..XX.....XXX .XXX.X...XXX.....XXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX XXXXXXX.XXX.XXXXXXXX XXXXXXXXX.XXXXXXXXXX XXXXXXX.XXX.XXXXXXXX """ return game_map
def get_game_variables(constants): # instantiate entities fighter_component = Fighter(hp=100, defense=1, power=2) inventory_component = Inventory(26) level_component = Level() equipment_component = Equipment() player = Entity(0, 0, '@', libtcod.white, "Player", blocks=True, render_order=RenderOrder.ACTOR, fighter=fighter_component, inventory=inventory_component, level=level_component, equipment=equipment_component) entities = [player] equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2) dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component) player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) # Instantiate world map. # Monsters will be added to entities upon map generation. game_map = GameMap(constants["map_width"], constants["map_height"]) game_map.make_map(constants["max_rooms"], constants["room_min_size"], constants["room_max_size"], constants["map_width"], constants["map_height"], player, entities) message_log = MessageLog(constants["message_panel_x"], constants["message_panel_width"], constants["message_panel_height"]) # first turn in world should be player's game_state = GameStates.PLAYER_TURN return player, entities, game_map, message_log, game_state