Exemplo n.º 1
0
    def load_game(self):
        #open the previously saved shelve and load the game data
#        file = open('savegame.sav', 'rb')
#         self.map = pickle.load(file)
#         self.map.objects = pickle.load(file)
#         self.player = pickle.load(file)
#         self.map.player = self.player        
#         self.screen = Screen()
#         self.screen.game_msgs = pickle.load(file)
#         self.screen.fov_map = pickle.load(file)
#         self.screen.fov_recompute = pickle.load(file)
#         self.game_state = pickle.load(file)
#         self.map.stairs = pickle.load(file)
        file = shelve.open('savegame.s', 'r')
        self.map = file['map']
        self.map.objects = file['objects']
        self.player = file['player']
        self.screen.fov_map = file['fov_map']
        self.screen.fov_recompute = file['fov_recompute']
        self.screen.game_msgs = file['game_msgs']
        self.game_state = file['game_state']
        self.map.stairs = file['stairs']
               
        file.close()
        self.map.player = self.player
        self.map.screen = self.screen
        self.map.update_player_bindings()
        self.map.initialize_fov()
        libtcod.sys_set_fps(self.screen.LIMIT_FPS)
Exemplo n.º 2
0
	def __init__(self, app_name='test app', screen_width=None, screen_height=None):
		print '__init__'
		if screen_width is None:
			screen_width, screen_height = self.SCREEN_WIDTH, self.SCREEN_HEIGHT
		libtcod.console_init_root(
			screen_width, screen_height, app_name, False
		)

		self.game_msgs = []
		global message
		message = self.message

		self.game_state = 'playing'
		self.player_action = 'didnt-take-turn'

		x,y = None,None

		self.con = libtcod.console_new(self.MAP_WIDTH, self.MAP_HEIGHT)
		self.panel = libtcod.console_new(self.SCREEN_WIDTH, self.PANEL_HEIGHT)
		self.cursor = Cursor(self.con, 'X', 0,0)

		self.key = libtcod.Key()
		self.mouse = libtcod.Mouse()

		libtcod.sys_set_fps(self.LIMIT_FPS)
Exemplo n.º 3
0
def init():
    libtcod.console_set_custom_font('terminal12x12_gs_ro.png',
                                    libtcod.FONT_TYPE_GREYSCALE |
                                    libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                              'basicroguelike', False)
    libtcod.sys_set_fps(LIMIT_FPS)
Exemplo n.º 4
0
    def __init__(self, mouse=None, key=None):
        # initialize the console
        # set the font, and consoles
        libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(self.SCREEN_WIDTH, self.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
        self.con = libtcod.console_new(self.MAP_WIDTH, self.MAP_HEIGHT)
        self.panel = libtcod.console_new(self.SCREEN_WIDTH, self.PANEL_HEIGHT)
        libtcod.sys_set_fps(self.LIMIT_FPS)

        # create the tile colors
        self.color_dark_wall = libtcod.Color(0, 0, 100)
        self.color_dark_ground = libtcod.Color(50, 50, 100)
        self.color_light_wall = libtcod.Color(130, 110, 50)
        self.color_light_ground = libtcod.Color(200, 180, 50)

        # set the fov initially to None.  This will be generated properly when the map is rendered
        self.fov_map = None
        self.fov_recompute = False

        # set the mous and keyboard capture vars
        self.mouse = mouse
        self.key = key

        # set the message console
        self.game_msgs = []
Exemplo n.º 5
0
def boot():
	global SCREEN

	framework.events.register_event('draw', blit)

	tcod.console_set_custom_font(os.path.join('data', 'tiles', 'dejavu_wide12x12_gs_tc.png'),#,'consolas10x10_gs_tc.png')
	                             flags=tcod.FONT_LAYOUT_TCOD|tcod.FONT_TYPE_GREYSCALE)
	tcod.console_init_root(constants.WINDOW_WIDTH,
	                       constants.WINDOW_HEIGHT,
	                       constants.WINDOW_TITLE,
	                       fullscreen='--fullscreen' in sys.argv,
	                       renderer=tcod.RENDERER_GLSL)
	tcod.console_set_keyboard_repeat(200, 0)
	tcod.sys_set_fps(constants.FPS)	
	tcod.mouse_show_cursor(constants.SHOW_MOUSE)

	SCREEN['c'] = numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int32)
	SCREEN['d'] = '0'*(constants.WINDOW_HEIGHT*constants.WINDOW_WIDTH)
	SCREEN['r'] = []

	SCREEN['f'] = []
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['f'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))

	SCREEN['b'] = []
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
	SCREEN['b'].append(numpy.zeros((constants.WINDOW_HEIGHT, constants.WINDOW_WIDTH), dtype=numpy.int16))
Exemplo n.º 6
0
    def main_menu(self):
        """THE main menu, no other."""
        LIMIT_FPS = 20
        libtcod.sys_set_fps(LIMIT_FPS)

        img = libtcod.image_load('main/lazor.png')

        while not libtcod.console_is_window_closed():
            #show the background image, at twice the regular console resolution
            libtcod.image_blit_2x(img, 0, 0, 0)

            #show the game's title, and credits
            libtcod.console_set_default_foreground(0, color_menu_text)
            libtcod.console_print_ex(0, SCREEN_WIDTH/2, 1, libtcod.BKGND_NONE, libtcod.CENTER, 'Laz0r Dodging Game')
            libtcod.console_print_ex(0, SCREEN_WIDTH/2, 2, libtcod.BKGND_NONE, libtcod.CENTER, 'by magikmw')

            #show options and wait for the player's choice
            choice = menu('Choose an option:\n', ['Real-Time', 'Turn-Based', 'Highscores', 'Help', 'Quit.'], 18, -10)

            if choice == 0: #new game
                self.new_game('RT')
            if choice == 1:
                self.new_game('TB')
            if choice == 2:
                #TODO the highscore function call here
                pass
            if choice == 3:
                #TODO help screen funcion call here
                pass
            if choice == 4: #quit
                break
Exemplo n.º 7
0
    def __init__(self):
        
        logg.info('Main loop initialization.')

        logg.debug('Font size set to 8')
        libtcod.console_set_custom_font('main/terminal8x8_gs_ro.png',
            libtcod.FONT_LAYOUT_ASCII_INROW | libtcod.FONT_TYPE_GRAYSCALE)

        logg.debug('Main console initialization.')
        libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
            WINDOW_TITLE + ' v.' + VERSION, False,
                renderer = libtcod.RENDERER_SDL)
        logg.debug('Setting the FPS limit.')
        libtcod.sys_set_fps(LIMIT_FPS)
        logg.debug('Drawing console initialization.')
        self.con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
        #bottom panel console
        logg.debug('Panels console initialization.')
        self.top_panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
        self.bottom_panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

        logg.debug('Gamestate variables initialization')
        self.entities=[]
        self.player = None
        self.gamestate = ""
        self.player_action = None
        self.map = None
        self.random = libtcod.random_new()
        self.score = 0
        self.gamemode = ''
Exemplo n.º 8
0
def main():
    logging.basicConfig(filename='log.txt',level=logging.DEBUG,filemode='w')

    logging.debug('start of main')

    #initialize main console
    font_file = 'data/fonts/terminal10x10_gs_tc.png'
    libtcod.console_set_custom_font(font_file, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_W,SCREEN_H,'GolemRL')
    libtcod.sys_set_fps(LIMIT_FPS)

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_ANY,key,mouse)
        choice = main_menu()
        if choice == 0:
            seed = random.randrange(10000)
            print 'Seed %i'%seed
            logging.info('Starting new game with seed %i' % seed)
            game = new_game()#seed)
            game.play()
        elif choice == 1:
            game = load_game()
            game.play()
        elif choice == 2:
            break

    logging.debug('end of main')
    return 0
Exemplo n.º 9
0
	def __init__(self):
		self.screen = console.Screen(WIDTH, HEIGHT+5)
		self.console = console.Console(WIDTH, HEIGHT, self.screen)
		self.message_console = console.Console(WIDTH, 5, self.screen, (0,HEIGHT))
		self.messages = text_display.MessageBox(self.message_console, 5, (10,0), 'msg')
		self.fps_display = text_display.Label(self.message_console, (0,0), None)

		self.terrain_registry = map.TerrainRegistry()
		self.terrain_registry.load_from_file('data/terrain.yml')
		self.map = map.Map(200,200, self.terrain_registry)
		self.tc_events = events.TCODEventHandler()
		self.events = events.EventHandler()

		self.player = player.Player(4,5, self.map, combat.Adventurer.randomize())
		self.player_stat = text_display.TextBox(self.message_console, 4, (0,1))
		self.player.claim_display(self.player_stat)
		player.ArrowHandler(self.player, self.tc_events)

		self.actors = [self.player]
		for x in range(40):
			self.actors.append(overlay.AIActor(random.randrange(WIDTH), random.randrange(HEIGHT), self.map))
		self.player.register_event('update', self.tick_actors)

		self.objects = []
		for x in range(50):
			self.objects.append(overlay.Potion(random.randrange(WIDTH), random.randrange(HEIGHT), self.map))

		tc.sys_set_fps(30)
Exemplo n.º 10
0
 def __init__(self, debug = False):
     from harmless7drl import getCfg
     self.width = getCfg( "tcod", "width", 80, int )
     self.height = getCfg( "tcod", "height", 25, int )
     self.fps_limit = 20
     self.font_name = getCfg( "tcod", "font", "fonts/harmless-font-13x23.png" )
     self.font_layout = {
         "tcod":  libtcod.FONT_LAYOUT_TCOD,
         "ascii_incol":  libtcod.FONT_LAYOUT_ASCII_INCOL,
         "ascii_inrow":  libtcod.FONT_LAYOUT_ASCII_INROW,
     }[getCfg( "tcod", "fontlayout", "tcod" )]
     self.title = 'Harmless7DRL'
     self.colours = {
         'white': libtcod.white,
         'black': libtcod.black,
         'red': libtcod.red,
         'blue': libtcod.blue,
         'cyan': libtcod.cyan,
         'green': libtcod.green,
         'magenta': libtcod.magenta,
         'yellow': libtcod.yellow,
     }
     for key in self.colours.keys():
         self.colours["bold-"+key] = self.colours[key]
     for key in self.colours:
         if "bold" not in key:
             c = self.colours[key]
             self.colours[key] = libtcod.Color( c.r & 0x80, c.g & 0x80, c.b & 0x80 )
     from widgets import PrimaryColourRGB, SecondaryColourRGB, BorderColourRGB, HighlightPrimaryColourRGB, HighlightSecondaryColourRGB
     self.colours[ "tcod-primary" ] = libtcod.Color( *PrimaryColourRGB )
     self.colours[ "tcod-secondary" ] = libtcod.Color( *SecondaryColourRGB )
     self.colours[ "tcod-primary-hl" ] = libtcod.Color( *HighlightPrimaryColourRGB )
     self.colours[ "tcod-secondary-hl" ] = libtcod.Color( *HighlightSecondaryColourRGB )
     self.colours[ "tcod-border" ] = libtcod.Color( *BorderColourRGB )
     self.colours["bold-black"] = libtcod.Color( 0x80, 0x80, 0x80 )
     self.keymap = {
         libtcod.KEY_BACKSPACE: 'backspace',
         libtcod.KEY_KP1: 'southwest',
         libtcod.KEY_KP2: 'south',
         libtcod.KEY_KP3: 'southeast',
         libtcod.KEY_KP4: 'west',
         libtcod.KEY_KP6: 'east',
         libtcod.KEY_KP7: 'northwest',
         libtcod.KEY_KP8: 'north',
         libtcod.KEY_KP9: 'northeast',
         libtcod.KEY_END: 'southwest',
         libtcod.KEY_DOWN: 'south',
         libtcod.KEY_PAGEDOWN: 'southeast',
         libtcod.KEY_LEFT: 'west',
         libtcod.KEY_RIGHT: 'east',
         libtcod.KEY_HOME: 'northwest',
         libtcod.KEY_UP: 'north',
         libtcod.KEY_PAGEUP: 'northeast',
         libtcod.KEY_ENTER: '\n',
         libtcod.KEY_ESCAPE: 'escape',
     }
     libtcod.console_set_custom_font( self.font_name,
                                      libtcod.FONT_TYPE_GREYSCALE | self.font_layout)
     libtcod.console_init_root(self.width, self.height, self.title, False)
     libtcod.sys_set_fps( self.fps_limit )
Exemplo n.º 11
0
def main():
    global key, mouse, map_, con
    
    R.SCREEN_WIDTH = 100
    R.SCREEN_HEIGHT = 80
    libtcod.console_set_custom_font("data\ont_big.png",libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(R.SCREEN_WIDTH, R.SCREEN_HEIGHT, "Trader-RL", False)
    libtcod.sys_set_fps(R.LIMIT_FPS)        
    con = libtcod.console_new(R.SCREEN_WIDTH, R.SCREEN_HEIGHT)     
    
    
    map_ = Map(R.MAP_WIDTH,R.MAP_HEIGHT)        
    map_.wind_gen.run_simulation(500)
    
    mouse = libtcod.Mouse()
    key = libtcod.Key()
    
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS|libtcod.EVENT_MOUSE, key, mouse)
        render()        
            
        
        player_action = handle_keys()
        if player_action == "exit":    
            break
        
        handle_mouse()
Exemplo n.º 12
0
def run():
	os.putenv("SDL_VIDEO_CENTERED", "1")
	if not os.path.exists('saves'):
		os.makedirs('saves')
	if not os.path.exists('maps'):
		os.makedirs('maps')
	libtcod.sys_set_fps(400)
	Game()
Exemplo n.º 13
0
def screen():
    global con, panel
    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, 16,16)
    libtcod.console_set_custom_font('menu_background1.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, 16,16)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Try not to Die!', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
    panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
    objects = []
Exemplo n.º 14
0
 def init(self): #init tcod & such
     global turn_log
     tcod.console_init_root(GAME_WIDTH,GAME_HEIGHT,'deth')
     tcod.console_set_default_background(0, tcod.darkest_gray)
     tcod.sys_set_fps(15)
     
     turn_log = '\b'
     
     self.menu()
Exemplo n.º 15
0
def programSetup():
    libtcod.console_set_custom_font(
        const.fontName,
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.sys_set_fps(const.fps)
    libtcod.console_init_root(const.consoleWidth, const.consoleHeight,
                              'Stay in the Light')
    libtcod.console_set_default_foreground(const.root, libtcod.white)
    libtcod.console_clear(const.root)
    gEngine.drawUILines()
Exemplo n.º 16
0
def play_game():
    
    tcod.console_init_root(settings.SCREEN_W, settings.SCREEN_H, 'SteamPocalypse')
    tcod.sys_set_fps(20)
    
    while not tcod.console_is_window_closed():

        engine.engine.handle_input()
        
        engine.engine.render_all()
Exemplo n.º 17
0
def init_libtcod():
    libtcod.console_set_custom_font(FONT_FILE_PATH,
                                    libtcod.FONT_LAYOUT_ASCII_INROW |
                                    libtcod.FONT_TYPE_GREYSCALE,
                                    16, 34)
    libtcod.console_init_root(settings.SCREEN_WIDTH,
                              settings.SCREEN_HEIGHT,
                              b'The Last Rogue',
                              settings.FULL_SCREEN)
    fps = settings.FPS
    libtcod.sys_set_fps(fps)
Exemplo n.º 18
0
    def __init__(self):
        flags = libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD
        libtcod.console_set_custom_font(self.font, flags)
        libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'mprl', False)
        libtcod.sys_set_fps(LIMIT_FPS)

        self.con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
        self.panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
        self.inv_window = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)

        self.hp_bar = UIBar('HP', libtcod.darker_red, libtcod.light_red)
Exemplo n.º 19
0
 def __init__(self, player_controls, conway_speed, map_size, fps, color,
              paddle_size, seamless):
     self.width, self.height = map_size
     self.init_players(player_controls, paddle_size)
     self.init_map(map_size, color)
     (w, h) = map_size
     tcod.console_init_root(w, h, config.GAME_TITLE, False)
     tcod.sys_set_fps(fps)
     self.conway_speed = conway_speed
     self.ball = Ball(1, 1)
     self.seamless = seamless
Exemplo n.º 20
0
def game_initialize():
    libtcod.console_set_custom_font('oryx_tiles3.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD, 32, 12)
    libtcod.console_init_root(data.SCREEN_WIDTH, data.SCREEN_HEIGHT, 'MeFightRogues!', False, libtcod.RENDERER_SDL)
    libtcod.sys_set_fps(data.LIMIT_FPS)

    libtcod.console_map_ascii_codes_to_font(256   , 32, 0, 5)  #map all characters in 1st row
    libtcod.console_map_ascii_codes_to_font(256+32, 32, 0, 6)  #map all characters in 2nd row

    Game.con = libtcod.console_new(data.MAP_WIDTH,data.MAP_HEIGHT)
    Game.panel = libtcod.console_new(data.SCREEN_WIDTH, data.PANEL_HEIGHT)

    main_menu()
Exemplo n.º 21
0
def renderer_init():
    """
    Initialize libtcod and set up our basic consoles to draw into.
    """
    global _con, _panel, _overlay, _last_frame_time
    libtcod.console_set_custom_font('arial12x12.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(config.SCREEN_WIDTH, config.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    _con = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _overlay = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _panel = libtcod.console_new(config.SCREEN_WIDTH, config.PANEL_HEIGHT)
    _last_frame_time = time.time() * 1000
Exemplo n.º 22
0
def init():
    # init window
    font = os.path.join(b'resources', b'consolas10x10_gs_tc.png')
    libtcod.console_set_custom_font(font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(SCREEN_SIZE.x, SCREEN_SIZE.y, b'DalekRL')
    libtcod.sys_set_fps(LIMIT_FPS)

    # set default text palette # TODO: merge with UI class statics
    libtcod.console_set_color_control(libtcod.COLCTRL_1,libtcod.red,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_2,libtcod.dark_yellow,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_3,libtcod.light_green,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_4,libtcod.light_blue,libtcod.black)
    libtcod.console_set_color_control(libtcod.COLCTRL_5,libtcod.purple,libtcod.black)
Exemplo n.º 23
0
    def __init__(self, title='Game'):
        self.state = 1
        self.map = None
        self.rooms = []
        self.numRooms = 0
        self.objects = []
        self.player = None


        # Actual surface you see
        l.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, title, False)
        l.sys_set_fps(LIMIT_FPS)

        # Hidden work surface for all the calculations/changes
        self.canvas = l.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

        # Secondary layer for field of vision purposes
        self.fov = l.map_new(MAP_WIDTH, MAP_HEIGHT)
        self.fovRecompute = True
        
        # Set up game/map here
        self.spawnPlayer()
        self.makeMap()
       
        for y in range(MAP_HEIGHT):
            for x in range(MAP_WIDTH):
                l.map_set_properties(self.fov,
                    x, y, not self.map[x][y].block_sight,
                    not self.map[x][y].blocked)
 
        # Blit is what updates the main surface to your work surface
        l.console_blit(self.canvas, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
        
        while(self.state):
            self.renderAll()

            l.console_blit(self.canvas, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
            l.console_flush()        

            # Remove old positions first
            for obj in self.objects:
                obj.clear()
    
            action = self.handleKeys()
            if action == 'exit':
                self.state = 0
                break
            elif self.state == 1 and action != 'didnt-take-turn':
                for obj in self.objects:
                    if obj.ai:
                        obj.ai.take_turn()
Exemplo n.º 24
0
def main():

    #actual size of the window
    SCREEN_WIDTH = 80
    SCREEN_HEIGHT = 50
     
    LIMIT_FPS = 20  #20 frames-per-second maximum

    raw_input("[INFO] Paina ENTER startataksesi.")

    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
     
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'ROQUELIKE', False)
     
    libtcod.sys_set_fps(LIMIT_FPS)

    taso = Taso(0)
    pelaaja = Liikkuja(1, 1, '@', taso)

    print("[DEBUG] LOOPPI ALKAA")

    while not libtcod.console_is_window_closed():
     
        libtcod.console_set_default_foreground(0, libtcod.white)

        print("[DEBUG] DRAW FUNKTIOTA KUTSUTAAN")

        taso.kartta.draw(0)

        pelaaja.draw(0)
        libtcod.console_flush()

        print("[DEBUG] odotetaan nappulaa")

        nappula = libtcod.console_wait_for_keypress(True)

        print("[DEBUG] Nappula saatu")

        if nappula.vk == libtcod.KEY_ESCAPE:
            return
        elif nappula.vk == libtcod.KEY_RIGHT:
            pelaaja.liiku((1, 0))
        elif nappula.vk == libtcod.KEY_LEFT:
            pelaaja.liiku((-1, 0))
        elif nappula.vk == libtcod.KEY_UP:
            pelaaja.liiku((0, -1))
        elif nappula.vk == libtcod.KEY_DOWN:
            pelaaja.liiku((0, 1))
        else:
            print("tuntematon nappain, ei virheita")
Exemplo n.º 25
0
def main_init():
    global con, con_char, inf,minmap, message_bar, date, ui, game_msgs
    #libtcod.console_set_custom_font("dejavu16x16.png", libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_set_custom_font("data\ont_big.png",libtcod.FONT_LAYOUT_ASCII_INROW)
    libtcod.console_init_root(R.SCREEN_WIDTH, R.SCREEN_HEIGHT, "Trader-RL", False)
    libtcod.sys_set_fps(R.LIMIT_FPS)
    con = R.con = libtcod.console_new(R.MAP_WIDTH, R.MAP_HEIGHT)
    con_char = R.con_char = libtcod.console_new(R.MAP_WIDTH, R.MAP_HEIGHT)
    inf = R.inf = libtcod.console_new(R.INFO_BAR_WIDTH, R.SCREEN_HEIGHT - R.PANEL_HEIGHT)
    minmap = R.minmap = libtcod.console_new(R.INFO_BAR_WIDTH, R.PANEL_HEIGHT)
    message_bar = R.message_bar = libtcod.console_new(R.PANEL_WIDTH, R.PANEL_HEIGHT)
    
    game_msgs = R.game_msgs = []
    ui = R.ui = UI.UI(con,game_msgs)
    date = R.date = [0, [DAYS[0][0], 1, 1], [MONTHS[0][0], 1, 31], 1000];
Exemplo n.º 26
0
def init():
	global SYMBOL_MAP, KEYBOARD_MAP, CON, UI, MOUSE, KEY
	w = config.SCREEN_WIDTH
	h = config.SCREEN_HEIGHT
	ltc.sys_set_fps(config.FPS)
	
	#ltc.console_set_custom_font(config.TILE_SET, ltc.FONT_LAYOUT_ASCII_INROW | ltc.FONT_TYPE_GREYSCALE, 16, 16)
	ltc.console_set_custom_font(config.TILE_SET, ltc.FONT_LAYOUT_TCOD | ltc.FONT_TYPE_GREYSCALE, 32, 8)	
	ltc.console_init_root(w, h, config.TITLE, False)
	
	KEYBOARD_MAP = dict([[v, k] for k, v in KEYBOARD_MAP.items()])
	CON = ltc.console_new(w, h)
	UI = ltc.console_new(w, h)
	ltc.console_set_key_color(UI, ltc.purple)
	MOUSE = ltc.Mouse()
	KEY = ltc.Key()
Exemplo n.º 27
0
def renderer_init():
    """
    Initialize libtcod and set up our basic consoles to draw into.
    """
    global _con, _panel, _overlay, _last_frame_time
    libtcod.console_set_custom_font('arial12x12.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    # Map the dead space in the TCOD layout to [128...164]
    # libtcod.console_map_ascii_codes_to_font(256, 21, 11, 1)
    # libtcod.console_map_ascii_codes_to_font(277, 25, 0, 2)
    libtcod.console_map_ascii_code_to_font(129, 12, 1)
    libtcod.console_init_root(config.SCREEN_WIDTH, config.SCREEN_HEIGHT, 'Beyaz Dag', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    _con = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _overlay = libtcod.console_new(config.MAP_PANEL_WIDTH, config.MAP_PANEL_HEIGHT)
    _panel = libtcod.console_new(config.SCREEN_WIDTH, config.PANEL_HEIGHT)
    _last_frame_time = time.time() * 1000
Exemplo n.º 28
0
Arquivo: r3.py Projeto: tanadrin/ma_py
    def __init__(self):
        #GUI and map variables
        self.SCREEN_WIDTH = 80
        self.SCREEN_HEIGHT = 50
        #MAP_X_SIZE and _Y_SIZE are the size of the map in chunks
        self.MAP_X_SIZE = 200
        self.MAP_Y_SIZE = 400
        self.CHUNK_SIZE = 128
        self.MAP_WIDTH = self.MAP_X_SIZE*self.CHUNK_SIZE
        self.MAP_HEIGHT = self.MAP_Y_SIZE*self.CHUNK_SIZE
        self.CAMERA_WIDTH = 80
        self.CAMERA_HEIGHT = 49
        self.LIMIT_FPS = 20
        self.INFOBAR_HEIGHT = 1
        self.ACTIONPANEL_WIDTH = 15
        self.MENU_WIDTH = 20
        self.GAME_FONT = 'arial10x10.png'
        #We begin in the center of this chunk
        self.PLAYER_START_X = 100
        self.PLAYER_START_Y = 200

        #Variable controlling frame interval for certain events
        self.GAMESPEED = 5

        #Minimum number of frames between player movements/actions
        self.MAX_MOVESPEED = self.GAMESPEED/2

        libtcod.console_set_custom_font(self.GAME_FONT, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        libtcod.console_init_root(self.SCREEN_WIDTH, self.SCREEN_HEIGHT, 'python/libtcod tutorial', False)
        libtcod.sys_set_fps(self.LIMIT_FPS)
        self.con = libtcod.console_new(self.SCREEN_WIDTH, self.SCREEN_HEIGHT)

        #Game state and GUI control variables
        self.show_menu = False
        self.mode = "move"
        self.cursor = None
        self.time = "free"
        self.player_wait = 0

        self.npcs = []
        self.player = None
        self.camera = None
        self.objects = []
        self.map = None

        self.infobar = libtcod.console_new(self.SCREEN_WIDTH, self.INFOBAR_HEIGHT)
        self.menu = libtcod.console_new(self.MENU_WIDTH, self.SCREEN_HEIGHT)
Exemplo n.º 29
0
def init_libtcod(terraform=False, window_size=WINDOW_SIZE, map_view_size=MAP_WINDOW_SIZE):
	global ITEM_WINDOW, CONSOLE_WINDOW, MESSAGE_WINDOW, PREFAB_WINDOW, X_CUTOUT_WINDOW, Y_CUTOUT_WINDOW
	
	_font_file = os.path.join(DATA_DIR, 'tiles', FONT)
	
	if '_incol' in FONT:
		_layout = tcod.FONT_LAYOUT_ASCII_INCOL
	elif '_inrow' in FONT:
		_layout = tcod.FONT_LAYOUT_ASCII_INROW
	
	if '_tiles' in FONT:
		_layout = _layout|tcod.FONT_TYPE_GRAYSCALE
	
	if '--worldmap' in sys.argv:
		MAP_WINDOW_SIZE[0] = 450
		MAP_WINDOW_SIZE[1] = 450
		window_size[0] = 450
		window_size[1] = 450
	
	tcod.console_set_custom_font(_font_file, _layout)
	tcod.console_init_root(window_size[0], window_size[1], WINDOW_TITLE, renderer=RENDERER)
	
	if terraform:
		PREFAB_WINDOW = tcod.console_new(PREFAB_WINDOW_SIZE[0],PREFAB_WINDOW_SIZE[1])
		X_CUTOUT_WINDOW = tcod.console_new(X_CUTOUT_WINDOW_SIZE[0],X_CUTOUT_WINDOW_SIZE[1])
		Y_CUTOUT_WINDOW = tcod.console_new(Y_CUTOUT_WINDOW_SIZE[0],Y_CUTOUT_WINDOW_SIZE[1])
		
		PREFAB_CHAR_BUFFER[0] = numpy.zeros((PREFAB_WINDOW_SIZE[1], PREFAB_WINDOW_SIZE[0]), dtype=numpy.int8)
		PREFAB_CHAR_BUFFER[1] = numpy.zeros((PREFAB_WINDOW_SIZE[1], PREFAB_WINDOW_SIZE[0]), dtype=numpy.int8)
		X_CUTOUT_CHAR_BUFFER[0] = numpy.zeros((X_CUTOUT_WINDOW_SIZE[1], X_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
		X_CUTOUT_CHAR_BUFFER[1] = numpy.zeros((X_CUTOUT_WINDOW_SIZE[1], X_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
		Y_CUTOUT_CHAR_BUFFER[0] = numpy.zeros((Y_CUTOUT_WINDOW_SIZE[1], Y_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
		Y_CUTOUT_CHAR_BUFFER[1] = numpy.zeros((Y_CUTOUT_WINDOW_SIZE[1], Y_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
	
	tcod.console_set_keyboard_repeat(200, 0)
	tcod.sys_set_fps(FPS)

	for i in range(3):
		if terraform:
			PREFAB_RGB_BACK_BUFFER[i] = numpy.zeros((PREFAB_WINDOW_SIZE[1], PREFAB_WINDOW_SIZE[0]), dtype=numpy.int8)
			PREFAB_RGB_FORE_BUFFER[i] = numpy.zeros((PREFAB_WINDOW_SIZE[1], PREFAB_WINDOW_SIZE[0]), dtype=numpy.int8)
			X_CUTOUT_RGB_BACK_BUFFER[i] = numpy.zeros((X_CUTOUT_WINDOW_SIZE[1], X_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
			X_CUTOUT_RGB_FORE_BUFFER[i] = numpy.zeros((X_CUTOUT_WINDOW_SIZE[1], X_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
			Y_CUTOUT_RGB_BACK_BUFFER[i] = numpy.zeros((Y_CUTOUT_WINDOW_SIZE[1], Y_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
			Y_CUTOUT_RGB_FORE_BUFFER[i] = numpy.zeros((Y_CUTOUT_WINDOW_SIZE[1], Y_CUTOUT_WINDOW_SIZE[0]), dtype=numpy.int8)
	
	SETTINGS['light mesh grid'] = numpy.meshgrid(range(map_view_size[0]), range(map_view_size[1]))
Exemplo n.º 30
0
	def __init__(self, screen_width, screen_height, fps_limit):
		# store values
		self.screen_width = screen_width
		self.screen_height = screen_height
		self.fps_limit = fps_limit

		# turn on fps limit if > 0
		if self.fps_limit > 0:
			logger.log(logger.types.rendering, "FPS limiter set to " + str(self.fps_limit))
			libtcod.sys_set_fps(self.fps_limit)

		# import font
		libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
		# root console / main window / 0
		self.rootcon = libtcod.console_init_root(self.screen_width, self.screen_height, 'Ghreborn', False)	
		# init primary console
		self.con = libtcod.console_new(self.screen_width, self.screen_height)
Exemplo n.º 31
0
import libtcodpy as libtcod
from logic.menu_main import MenuMain
from logic.menu_manager import MenuManager

screen_width = 75
screen_height = 75
limit_fps = 30

menu_manager = MenuManager(MenuMain(screen_width, screen_height))

libtcod.console_disable_keyboard_repeat()

libtcod.console_set_custom_font('cp437_10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
libtcod.console_init_root(screen_width, screen_height, 'RogueP pre-dev', False)
libtcod.sys_set_fps(limit_fps)

while not libtcod.console_is_window_closed():
	#behavior_manager.update_behaviors(entities)
	if not menu_manager.loop(round(libtcod.sys_get_last_frame_length()*1000)):
		break
Exemplo n.º 32
0
			libtcod.console_set_custom_font(_font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
		except:
			logging.error('Failed to load font!')
			sys.exit()
	else:
		var.window_size = (80,50)
		libtcod.console_set_custom_font(os.path.join('data','terminal16x16_aa_tc.png'), libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
	libtcod.console_init_root(var.window_size[0], var.window_size[1], 'Rogue Caves - %s' % __version__, False)
	var.view = libtcod.console_new(var.window_size[0], var.window_size[1]-6)
	var.tree = libtcod.console_new(var.window_size[0], var.window_size[1]-6)
	var.splatter = libtcod.console_new(var.window_size[0], var.window_size[1]-6)
	libtcod.console_set_key_color(var.splatter,libtcod.Color(0,0,0))
	libtcod.console_set_key_color(var.tree,libtcod.Color(0,0,0))
	var.log = libtcod.console_new(var.window_size[0], 6)
	libtcod.console_set_keyboard_repeat(100,1)
	libtcod.sys_set_fps(var.max_fps)
	
	_logofile = open(os.path.join('data','logo.txt'),'r')
	_y=18
	for line in _logofile.readlines():
		_i = 1
		for char in line:
			if char == '\n': continue
			libtcod.console_set_char_foreground(0,_i,_y,libtcod.Color(_y*6,_y*6,_y*6))
			#libtcod.console_print(0, _i, _y, char)
			libtcod.console_set_char(0, _i, _y, char)
			_i+=1
		_y+=1
	libtcod.console_print(0,(var.window_size[0]/2)-(len(__version__)/2),
		28,
		str(__version__))
Exemplo n.º 33
0
#usr/bin/env/python3
import libtcodpy as tcod

#INITIALIZING CONSOLE AND STATING VARIABLES:

SCREEN_WIDTH = 72
SCREEN_HEIGHT = 42
FPS_LIMIT = 30

window_title = "Window Title"
fullscreen = False
tcod.console_set_custom_font(
    "terminal16x16_gr_ro.png",
    tcod.FONT_LAYOUT_ASCII_INROW | tcod.FONT_TYPE_GREYSCALE)

tcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, window_title, fullscreen)
tcod.sys_set_fps(FPS_LIMIT)

#MAIN LOOP:

while not tcod.console_is_window_closed():
    tcod.console_flush()
Exemplo n.º 34
0
    'whamm', 'whammm', 'whap', 'zap', 'zlonk', 'zok', 'zowie', 'kerrrip'
]
#pickup message prefixes
pickup_prefix_msg = [
    'nice', 'sweet', 'cool', 'yes', 'alright', 'that\'s it', 'super', 'amok',
    'hey', 'neat', 'sick', 'woo', 'whoa', 'right on', 'yeah', 'good', 'great',
    'not bad', 'superb', 'excellent'
]
#sets font and root console properties
libtcod.console_set_custom_font(
    'terminal12x12.png',
    libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT,
                          'python/libtcod WASTEOID ' + VERSION, False,
                          libtcod.RENDERER_SDL)
libtcod.sys_set_fps(LIMIT_FPS)  #FPS limit
#creates an offscreen console and a log panel
con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
log_panel = libtcod.console_new(SCREEN_WIDTH, LOG_PANEL_HEIGHT)
#makes map and fov map - called fov_init to avoid confusion with fov_map object
make_map()
fov_init()

#sets regen rate for all Fighters
regen_timer = HEALTH_REGEN_RATE
#sets timers for basic needs
hunger_timer = HUNGER_RATE
thirst_timer = THIRST_RATE

fov_recompute = True
game_state = 'playing'
Exemplo n.º 35
0
def start_console():
    libtcod.console_init_root(WIDTH, HEIGHT, "FabSec", False,
                              libtcod.RENDERER_SDL)
    libtcod.sys_set_fps(60)
Exemplo n.º 36
0
	#render_bar(1,1,BAR_WIDTH,'HP',player.body.hp,player.body.max_hp,libtcod.light_red,libtcod.darker_red)

	libtcod.console_set_default_foreground(panel,libtcod.light_gray)
	libtcod.console_print_ex(panel,1,0,libtcod.BKGND_NONE,libtcod.LEFT,get_names_under_mouse())


	#blit the panel to the screen
	libtcod.console_blit(panel,0,0,SCREEN_WIDTH,PANEL_HEIGHT,0,0,PANEL_Y)


	#blit our off-screen console
	libtcod.console_blit(con,0,0,MAP_WIDTH,MAP_HEIGHT,0,0,0)

#################################################################################################

libtcod.sys_set_fps(LIMIT_FPS)

#creating our character object and components

blarm = limbArm(name='bruiser left arm', hp=15, strength=15)
brarm = limbArm(name='bruiser right arm', hp=15, strength=18)
blleg = limbLeg(name='bruiser left leg', hp=20,strength=10,speed=3)
brleg = limbLeg(name='bruiser left leg', hp=20,strength=10,speed=3)
bhead = limbHead(name='bruiser head',hp=10)
btorso= limbTorso(name='bruiser torso',hp=80)
blms = [btorso,blarm,brarm,blleg,brleg,bhead]
cbody = Body(limbs=blms)

player = Object(0,0,'@','the ultimate warrior',libtcod.white,blocks = True, body=cbody)
objects = [player]
Exemplo n.º 37
0
                    self.map_arr[xx + self.room_size][yy +
                                                      self.room_size] = " "

##===============================================================================

    def getMap(self):
        ##===============================================================================
        return self.map_arr


#Just for testing ;)
if __name__ == "__main__":
    Main_Console = libtcod.console_init_root(Game_Screen_Width,
                                             Game_Screen_Height,
                                             "Lost Horizon 0.0.1a", False)
    libtcod.sys_set_fps(25)
    map = GenDungeon(50, 50, var=50)
    map_arr = map.getMap()
    pix = libtcod.image_new(len(map_arr), len(map_arr))
    for x in range(len(map_arr)):
        for y in range(len(map_arr)):
            if map_arr[x][y] == "#":
                libtcod.image_put_pixel(pix, x, y, libtcod.dark_grey)
            if map_arr[x][y] == " ":
                libtcod.image_put_pixel(pix, x, y, libtcod.white)
    while not libtcod.console_is_window_closed():
        #libtcod.image_blit(pix,0,50,50,libtcod.BKGND_SET,1.0,1.0,0.0)
        libtcod.image_blit_2x(pix, 0, 0, 0)
        libtcod.console_flush()
        key = libtcod.console_check_for_keypress(libtcod.KEY_PRESSED)
        if key.vk == libtcod.KEY_ESCAPE:
Exemplo n.º 38
0
def main():

    player = Object(1, 1, '@', libtcod.red)

    libtcod.console_set_custom_font(
        'arial12x12.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    # specify screen size, title and whether or not fullscreen for root console
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'maze game', False)

    # off-screen console for the map
    con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)

    # off-screen console for display panel
    panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

    # Only for real time, Frames per second
    libtcod.sys_set_fps(LIMIT_FPS)

    fov_map = libtcod.map_new(MAP_WIDTH, MAP_HEIGHT)
    global compute_fov
    compute_fov = False

    cells = [[Cell() for y in range(MAP_COLS)] for x in range(MAP_ROWS)]

    make_map(cells)

    msgs = []
    choice = 0

    global move_count
    move_count = 0

    while True:

        msgs.append(("Which algorithm would you like to generate the maze?",
                     libtcod.white))
        msgs.append(("[1]. Kruskal's algorithm", libtcod.white))
        msgs.append(("[2]. Prim's algorithm", libtcod.white))
        msgs.append(("[3]. Binary tree method", libtcod.white))
        msgs.append(("[4]. Random method", libtcod.white))

        render_all(player, con, panel, fov_map, True, msgs)
        libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
        libtcod.console_flush()

        msgs = []

        form_messages = [
            ("Maze has been formed by Kruskal's method", libtcod.green),
            ("Maze has been formed by Prim's method", libtcod.green),
            ("Maze has been formed by Binary tree method", libtcod.green)
        ]

        key = libtcod.console_wait_for_keypress(True)

        if key.vk == libtcod.KEY_1:
            choice = 1

        if key.vk == libtcod.KEY_2:
            choice = 2

        if key.vk == libtcod.KEY_3:
            choice = 3

        if key.vk == libtcod.KEY_4:
            choice = random.randint(0, 3)

        if choice in [1, 2, 3]:
            print "User's choice for maze generation is " + str(choice)
            msgs.append(form_messages[choice - 1])
            break

        else:
            msgs.append(("Sorry that is not an option!", libtcod.red))
            msgs.append(("", libtcod.red))

    if choice == 1:
        (edges, cell_set, cell_list,
         cells) = kruskal.init_variables(MAP_ROWS, MAP_COLS)

        while cell_set.size() != 1:
            cells = kruskal.generate_maze(edges, cell_set, cell_list, cells)

    if choice == 2:
        (wall_set, cells_finished,
         cells) = prim.init_variables(MAP_ROWS, MAP_COLS)

        while len(cells_finished) != MAP_ROWS * MAP_COLS:
            cells = prim.generate_maze(wall_set, cells_finished, cells,
                                       MAP_ROWS, MAP_COLS)

    if choice == 3:
        (cells) = bt.init_variables(MAP_ROWS, MAP_COLS)

        for x in range(MAP_ROWS - 1, -1, -1):
            for y in range(MAP_COLS):
                cells = bt.generate_maze(cells, x, y, MAP_ROWS, MAP_COLS)

    make_map(cells)

    msgs = in_game_messages(msgs)

    for y in xrange(MAP_HEIGHT):
        for x in xrange(MAP_WIDTH):
            libtcod.map_set_properties(fov_map, x, y, not map[x][y].wall,
                                       not map[x][y].wall)

    render_all(player, con, panel, fov_map, True, msgs)
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)
    libtcod.console_flush()

    global fog_of_war
    fog_of_war = True

    while not libtcod.console_is_window_closed():

        if player.x == MAP_WIDTH - 2 and player.y == MAP_HEIGHT - 2:
            msgs = []
            msgs.append(
                ("Congratulations! You have won the game", libtcod.purple))
            msgs.append(("", libtcod.white))
            msgs.append(
                ("Displaying player's route in green", libtcod.light_green))
            msgs.append(("", libtcod.white))
            msgs.append(("Press any key to exit game now", libtcod.white))
            render_all(player, con, panel, fov_map, False, msgs)
            render_travelled(con)
            libtcod.console_put_char_ex(con, 1, 1, 'S', libtcod.pink,
                                        libtcod.black)
            player.draw(con)
            libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0,
                                 0)
            libtcod.console_flush()

            key = libtcod.console_wait_for_keypress(True)
            break

        render_all(player, con, panel, fov_map, fog_of_war, msgs)

        libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
        libtcod.console_flush()

        player.erase(con)

        quit = keyboard_input(player, con)

        if quit:
            quit_msgs = []
            quit_msgs.append(("Are you sure you want to quit?", libtcod.red))
            quit_msgs.append(("", libtcod.red))
            quit_msgs.append(("Enter Esc again to display solution and exit",
                              libtcod.white))
            quit_msgs.append(("Enter any other key otherwise", libtcod.white))

            render_all(player, con, panel, fov_map, True, quit_msgs)
            libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0,
                                 0)
            libtcod.console_flush()

            key = libtcod.console_wait_for_keypress(True)

            if key.vk == libtcod.KEY_ESCAPE:
                quit_msgs = []
                quit_msgs.append(("Displaying solution in blue", libtcod.sky))
                quit_msgs.append(("", libtcod.green))
                quit_msgs.append((
                    "Displaying player's route (not overlapping with solution) in green",
                    libtcod.light_green))
                quit_msgs.append(("", libtcod.green))
                quit_msgs.append(
                    ("Press any key to exit game now", libtcod.white))
                render_all(player, con, panel, fov_map, False, quit_msgs)
                render_travelled(con)
                render_solution(cells, con)
                player.draw(con)
                libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,
                                     0, 0)
                libtcod.console_flush()

                key = libtcod.console_wait_for_keypress(True)
                break
Exemplo n.º 39
0
            saveGame()
            break

        #monster turn
        if gameState == "playing" and playerAction != "did-not-move":
            for object in objects:
                if object.ai:
                    object.ai.takeATurn()


#########################
# System Initialization #
#########################
libtcod.console_set_custom_font(
    "arial10x10.png", libtcod.FONT_TYPE_GRAYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, GAME_TITLE,
                          False)  #False here is for fullscreen
libtcod.sys_set_fps(FPS_LIMIT)

con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
objects = []

##############
# Game Start #
##############
if DEBUG:
    newGame()
    playGame()
else:
    mainMenu()
Exemplo n.º 40
0
FOV_LIGHT_WALLS = True
TORCH_RADIUS = 10

HEAL_AMOUNT = 16
LIGHTNING_RANGE = 5
LIGHTNING_DAMAGE = 40
CONFUSE_NUM_TURNS = 10
CONFUSE_RANGE = 10
FIREBALL_RADIUS = 3
FIREBALL_DAMAGE = 25

# Experience and level-ups
LEVEL_UP_BASE = 200
LEVEL_UP_FACTOR = 150

tcod.sys_set_fps(LIMIT_FPS)

con = tcod.console_new(MAP_WIDTH, MAP_HEIGHT)
panel = tcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

colour_dark_wall = tcod.Color(0, 30, 0)
colour_dark_ground = tcod.Color(20, 60, 20)
colour_light_wall = tcod.Color(130, 110, 50)
colour_light_ground = tcod.Color(200, 180, 50)


class Equipment:
    # An object that can be equipped, yielding bonuses. Automatically adds the Item component.
    def __init__(self, slot, power_bonus=0, defense_bonus=0, max_hp_bonus=0):
        self.power_bonus = power_bonus
        self.defense_bonus = defense_bonus
Exemplo n.º 41
0
def new_game():
    global player, inventory, party, game_state, map, view_x, view_y, con, game_dir, text_color, music_paused
    music_paused = False
    f = open("./init.txt", "r")
    skipline(f)
    game_dir = (f.readline())
    f.close()
    # We need to get the screen size (and eventually we'll get other game data here as well)
    f = open(game_dir + "/init.txt", "r")
    # game name is line 2 of these, in case I want to do something with it
    skipline(f, 3)
    welcome_text = f.readline()
    skipline(f)
    red = int(f.readline())
    green = int(f.readline())
    blue = int(f.readline())
    skipline(f)
    text_color = libtcod.Color(int(f.readline()), int(f.readline()),
                               int(f.readline()))
    skipline(f)
    view_x = int(f.readline())
    view_y = int(f.readline())
    skipline(f)
    map = (f.readline()).rstrip()
    skipline(f)
    start_x = int(f.readline())
    start_y = int(f.readline())
    skipline(f)
    player_color = libtcod.Color(int(f.readline()), int(f.readline()),
                                 int(f.readline()))
    f.close()
    parsemap(map)
    # Boilerplate to set up the window
    LIMIT_FPS = 20  #20 frames-per-second maximum
    libtcod.console_set_custom_font(
        'dejavu16x16_gs_tc.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(view_x, view_y, 'RPG', False)
    libtcod.sys_set_fps(LIMIT_FPS)
    con = libtcod.console_new(view_x, view_y)
    libtcod.console_set_default_background(con,
                                           libtcod.Color(red, green, blue))
    continue_game = menu("File:", ["New", "Continue"])
    mixer.init()
    if continue_game == 1:
        try:
            load_game()
        except:
            display_text("No save file found! Starting new game...")
            continue_game = 0
    if not continue_game:
        display_text(welcome_text)
        # Initialize the player -
        player = Player(start_x,
                        start_y,
                        '@',
                        'player',
                        player_color, [], [],
                        blocks=True,
                        dir="up")
    print map.music
    if map.music != "none":
        mixer.music.load(map.music)
        mixer.music.set_volume(.5)
        mixer.music.play(-1)
    game_state = 'playing'
Exemplo n.º 42
0
def get_input():
	if var.output=='pygame':
		for event in pygame.event.get():
			if event.type == QUIT or event.type == KEYDOWN and event.key in [K_ESCAPE,K_q]:
				if var.in_menu:
					functions.destroy_menu(who=var.player)
				else:
					#var.world.save()
					pygame.quit()
					sys.exit()
			elif event.type == KEYDOWN:
				if event.key == K_UP:
					var.input['up'] = True
					var.menu_index-=1
				elif event.key == K_DOWN:
					var.input['down'] = True
					var.menu_index+=1
				elif event.key == K_LEFT:
					var.input['left'] = True
				elif event.key == K_RIGHT:
					var.input['right'] = True
				elif event.key == K_RETURN:
					if var.in_menu:
						functions.menu_select()
					else:
						var.player.enter()
						var.buffer = [[0] * var.world_size[1] for i in range(var.world_size[0])]
						region = (0,0,var.window_size[0]+1,var.window_size[1]+1)
						var.view.setbrightness(0, region=region)
						draw_screen(refresh=True)
				elif event.key == K_w:
					var.player.place_item(21,(0,-1))
				elif event.key == K_a:
					var.player.place_item(21,(-1,0))
				elif event.key == K_d:
					var.player.place_item(21,(1,0))
				elif event.key == K_s:
					var.player.place_item(21,(0,1))
				elif event.key == K_v:
					for pos in var.player.level.real_estate:
						var.view.tint(b=255,region=(pos[0],pos[1],1,1))
				elif event.key == K_b:
					if var.player.in_building(name='storage') and not var.in_menu:
						_building_owner = var.player.level.get_room('storage')['owner']
						
						if _building_owner and _building_owner.in_building(name='storage'):
							_menu = var.player.level.get_room_items('storage')
							if len(_menu):
								functions.build_menu(var.player.level.get_room_items('storage'),
									who=var.player,
									name='Shopping (Buy)',
									trading=True,
									callback=var.player.buy_item)
								_building_owner.say('What would you like today?')
							else:
								_building_owner.say('I have nothing to sell!')
				
				elif event.key == K_n:
					if var.player.in_building(name='storage') and not var.in_menu:
						_building_owner = var.player.level.get_room('storage')['owner']
						
						if _building_owner and _building_owner.in_building(name='storage'):
							functions.build_menu(var.player.items,
								who=var.player,
								name='Shopping (Sell)',
								trading=True,
								callback=var.player.sell_item,
								sell_to=_building_owner)
							_building_owner.say('What items do you have for me?')
							
				elif event.key == K_i:
					if len(var.player.items):
						functions.build_menu(var.player.items,
							name='Inventory',
							callback=var.player.equip_item)
				elif event.key == K_p:
					var.world.get_stats()
				elif event.key == K_1:
					var.player.teleport(1)
				elif event.key == K_2:
					var.player.teleport(0)
				elif event.key == K_3:
					var.player.teleport(-1)
				elif event.key == K_4:
					var.player.teleport(-2)
				elif event.key == K_5:
					var.player.teleport(-3)
				elif event.key == K_6:
					var.player.teleport(-4)
				elif event.key == K_j:
					logging.debug('Taking screenshot...')
					pygame.image.save(var.window._windowsurface, 'screenshot.jpg')
			elif event.type == KEYUP:
				if event.key == K_UP:
					var.input['up'] = False
				elif event.key == K_DOWN:
					var.input['down'] = False
				elif event.key == K_LEFT:
					var.input['left'] = False
				elif event.key == K_RIGHT:
					var.input['right'] = False
				elif event.key == K_z:
					var.max_fps = 20
				elif event.key == K_x:
					var.max_fps = 60
				elif event.key == K_c:
					var.max_fps = 10
				elif event.key == K_v:
					for pos in var.player.level.real_estate:
						var.view.setbrightness(0, region=(pos[0],pos[1],1,1))
			elif event.type == MOUSEMOTION:
				var.mouse_pos = var.view.getcoordinatesatpixel(event.pos)
			elif event.type == MOUSEBUTTONDOWN:
				for life in var.life:
					if life.z == var.player.z:
						if [life.pos[0]-var.camera[0],life.pos[1]-var.camera[1]] == list(var.mouse_pos):
							print '='*8
							print life.name
							print 'Task: %s' % life.task
							print 'Path: %s' % life.path
							print 'Path dest: %s' % str(life.path_dest)
							#print 'Path type: %s' % life.path_type
							print 'Position: %s' % str(life.pos)
							print 'Traits: %s' % life.traits
							print 'Attracted to: %s' % life.attracted_to
							print 'Likes: %s' % life.likes
							print 'Dislikes: %s' % life.dislikes
							#print [entry for entry in life.get_top_love_interests()]
							for event in life.events:
								print event['what'],event['score']
							print '='*8
							life.build_history()
							#print 'Inventory: '
							#for item in life.items:
							#	print item
				
				for item in var.player.level.items[var.mouse_pos[0]+var.camera[0]][var.mouse_pos[1]+var.camera[1]]:
					if [item['pos'][0]-var.camera[0],item['pos'][1]-var.camera[1]] == list(var.mouse_pos):
						print item
	else:
		key = libtcod.console_check_for_keypress(flags=libtcod.KEY_PRESSED) 
		
		if key.vk == libtcod.KEY_UP:
			var.input['up']=True
		else:
			var.input['up']=False
		
		if key.vk == libtcod.KEY_DOWN:
			var.input['down']=True
		else:
			var.input['down']=False
		
		if key.vk == libtcod.KEY_LEFT:
			var.input['left']=True
		else:
			var.input['left']=False
		
		if key.vk == libtcod.KEY_RIGHT:
			var.input['right']=True
		else:
			var.input['right']=False
		
		if key.vk == libtcod.KEY_ENTER:
			if var.in_menu:
				functions.menu_select()
			else:
				var.player.enter()
				var.buffer = [[0] * var.world_size[1] for i in range(var.world_size[0])]
				region = (0,0,var.window_size[0]+1,var.window_size[1]+1)
				libtcod.console_clear(var.view)
				draw_screen(refresh=True)
		
		if key.c == ord('x'):
			var.max_fps=60
			libtcod.sys_set_fps(var.max_fps)
		
		if key.c == ord('z'):
			var.max_fps=20
			libtcod.sys_set_fps(var.max_fps)
		
		if key.c == ord('c'):
			var.max_fps=10
			libtcod.sys_set_fps(var.max_fps)
		
		if key.vk in [libtcod.KEY_ESCAPE] or key.c == ord('q'):
			return True
	
	tick()
	return False
Exemplo n.º 43
0
def play_game(player, entities, game_map, message_log, game_state, con, panel,
              constants):
    fov_recompute = True

    fov_map = initialize_fov(game_map)

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    game_state = GameStates.PLAYERS_TURN
    previous_game_state = game_state

    targeting_item = None

    libtcod.sys_set_fps(24)

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if fov_recompute:
            recompute_fov(fov_map, player.x, player.y, constants['fov_radius'],
                          constants['fov_light_walls'],
                          constants['fov_algorithm'])

        render_all(con, panel, entities, player, game_map, fov_map,
                   fov_recompute, message_log, constants['screen_width'],
                   constants['screen_height'], constants['bar_width'],
                   constants['panel_height'], constants['panel_y'], mouse,
                   constants['colors'], game_state)

        fov_recompute = False

        libtcod.console_flush()

        clear_all(con, entities)

        action = handle_keys(key, game_state)
        mouse_action = handle_mouse(mouse)

        move = action.get('move')
        pickup = action.get('pickup')
        show_inventory = action.get('show_inventory')
        drop_inventory = action.get('drop_inventory')
        quick_inventory = action.get('quick_inventory')
        inventory_index = action.get('inventory_index')
        exit = action.get('exit')
        fullscreen = action.get('fullscreen')
        take_stairs = action.get('take_stairs')
        level_up = action.get('level_up')
        left_click = mouse_action.get('left_click')
        right_click = mouse_action.get('right_click')
        show_character_screen = action.get('show_character_screen')
        quickslot_index = action.get('quickslot_index')
        quick_slot = action.get('quick_use')
        examine_entity = action.get('examine_entity')

        enemies_afoot = False
        for entity in entities:
            if libtcod.map_is_in_fov(fov_map, entity.x,
                                     entity.y) and entity.ai:
                enemies_afoot = True
                break

        player_turn_results = []

        if right_click and game_state == game_state.PLAYERS_TURN and not enemies_afoot:
            (x, y) = mouse_action['right_click']
            move_target = lambda: None
            setattr(move_target, 'x', x)
            setattr(move_target, 'y', y)

            if game_map.tiles[x][y].explored:
                game_state = game_state.CLICK_MOVE

        if game_state == game_state.CLICK_MOVE:

            if enemies_afoot:
                game_state = game_state.ENEMY_TURN

            if game_state != game_state.ENEMY_TURN:
                if player.distance_to(move_target) < 1:
                    game_state = game_state.PLAYERS_TURN
                else:
                    if player.move_astar(move_target,
                                         entities,
                                         game_map,
                                         max_path=300,
                                         check_explored=True):
                        fov_recompute = True
                    else:
                        game_state = game_state.PLAYERS_TURN

        if (move or left_click or
            (enemies_afoot
             and right_click)) and game_state == GameStates.PLAYERS_TURN:
            if move:
                dx, dy = move
            else:
                if left_click:
                    target_x, target_y = mouse_action['left_click']
                else:
                    target_x, target_y = mouse_action['right_click']
                dx = target_x - player.x
                dy = target_y - player.y
                distance = math.sqrt(dx**2 + dy**2)

                if distance != 0:
                    dx = int(round(dx / distance))
                    dy = int(round(dy / distance))
                else:
                    dx = 0
                    dy = 0

            destination_x = player.x + dx
            destination_y = player.y + dy

            if not game_map.is_blocked(destination_x, destination_y):
                target = get_blocking_entities_at_location(
                    entities, destination_x, destination_y)

                if target and target != player:
                    attack_results = player.fighter.attack(target)
                    player_turn_results.extend(attack_results)
                elif target:
                    message_log.add_message(
                        Message('You take a short rest', libtcod.white))
                else:
                    player.move(dx, dy)

                    fov_recompute = True

                game_state = GameStates.ENEMY_TURN

        if pickup and game_state == GameStates.PLAYERS_TURN:
            for entity in entities:
                if entity.item and entity.x == player.x and entity.y == player.y:
                    pickup_results = player.inventory.add_item(entity)
                    player_turn_results.extend(pickup_results)

                    break
            else:
                message_log.add_message(
                    Message('There is nothing here to pick up.',
                            libtcod.yellow))

        if quick_slot:
            for item in player.inventory.items:
                if item.uID == player.quick_use.quick_list[quick_slot - 1]:
                    player_turn_results.extend(
                        player.inventory.use(item,
                                             entities=entities,
                                             fov_map=fov_map))

        if show_inventory:
            previous_game_state = game_state
            game_state = GameStates.SHOW_INVENTORY

        if drop_inventory:
            previous_game_state = game_state
            game_state = GameStates.DROP_INVENTORY

        if examine_entity:
            previous_game_state = game_state
            game_state = GameStates.EXAMINE_SCREEN

        if quick_inventory:
            previous_game_state = game_state
            game_state = GameStates.QUICK_USE

        if inventory_index is not None and previous_game_state != GameStates.PLAYER_DEAD and inventory_index < len(
                player.inventory.items):
            item = player.inventory.items[inventory_index]

            if game_state == GameStates.SHOW_INVENTORY:
                player_turn_results.extend(
                    player.inventory.use(item,
                                         entities=entities,
                                         fov_map=fov_map))
            elif game_state == GameStates.DROP_INVENTORY:
                player_turn_results.extend(player.inventory.drop_item(item))
            elif game_state == GameStates.QUICK_USE:
                player_turn_results.extend(player.quick_use.add_item(0, item))

        if take_stairs and game_state == GameStates.PLAYERS_TURN:
            for entity in entities:
                if entity.stairs and entity.x == player.x and entity.y == player.y:
                    entities = game_map.next_floor(player, message_log,
                                                   constants)
                    fov_map = initialize_fov(game_map)
                    fov_recompute = True
                    libtcod.console_clear(con)

                    break
            else:
                message_log.add_message(
                    Message('There are no stairs here.', libtcod.yellow))

        if level_up:
            if level_up == 'hp':
                player.fighter.max_hp += 20
                player.fighter.hp += 20
            elif level_up == 'str':
                player.fighter.base_power += 1
            elif level_up == 'def':
                player.fighter.base_defense += 1

            game_state = previous_game_state

        if show_character_screen:
            previous_game_state = game_state
            game_state = GameStates.CHARACTER_SCREEN

        if game_state == GameStates.TARGETING:
            if left_click:
                target_x, target_y = left_click

                item_use_results = player.inventory.use(targeting_item,
                                                        entities=entities,
                                                        fov_map=fov_map,
                                                        target_x=target_x,
                                                        target_y=target_y)
                player_turn_results.extend(item_use_results)
            elif right_click:
                player_turn_results.append({'targeting_cancelled': True})

        if exit:
            if game_state in (GameStates.SHOW_INVENTORY,
                              GameStates.DROP_INVENTORY,
                              GameStates.CHARACTER_SCREEN,
                              GameStates.QUICK_USE, GameStates.EXAMINE_SCREEN):
                game_state = previous_game_state
            elif game_state == GameStates.TARGETING:
                player_turn_results.append({'targeting_cancelled': True})
            elif game_state == GameStates.LEVEL_UP:
                level_up_menu(con, 'Level up! Choose a stat to raise:', player,
                              40, screen_width, screen_height)
            else:
                save_game(player, entities, game_map, message_log, game_state)

                return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

        # resolve and display the results
        for player_turn_result in player_turn_results:
            message = player_turn_result.get('message')
            dead_entity = player_turn_result.get('dead')
            item_added = player_turn_result.get('item_added')
            item_consumed = player_turn_result.get('consumed')
            item_dropped = player_turn_result.get('item_dropped')
            targeting = player_turn_result.get('targeting')
            targeting_cancelled = player_turn_result.get('targeting_cancelled')
            equip = player_turn_result.get('equip')
            xp = player_turn_result.get('xp')
            evoked = player_turn_result.get('evoked')
            item_slotted = player_turn_result.get('item_slotted')

            if message:
                message_log.add_message(message)

            if dead_entity:
                if dead_entity == player:
                    message, game_state = kill_player(dead_entity)
                else:
                    message = kill_monster(dead_entity)

                message_log.add_message(message)

            if item_slotted:
                game_state = GameStates.PLAYERS_TURN

            if item_added:
                entities.remove(item_added)

                game_state = GameStates.ENEMY_TURN

            if item_consumed or evoked:
                game_state = GameStates.ENEMY_TURN

            if item_dropped:
                entities.append(item_dropped)

                game_state = GameStates.ENEMY_TURN

            if equip:
                equip_results = player.equipment.toggle_equip(equip)

                for equip_result in equip_results:
                    equipped = equip_result.get('equipped')
                    unequipped = equip_result.get('unequipped')

                    if equipped:
                        message_log.add_message(
                            Message('You equipped the {0}'.format(
                                equipped.name)))

                    if unequipped:
                        message_log.add_message(
                            Message('You unequipped the {0}'.format(
                                unequipped.name)))

                game_state = GameStates.ENEMY_TURN

            if targeting:
                previous_game_state = GameStates.PLAYERS_TURN
                game_state = GameStates.TARGETING

                targeting_item = targeting

                message_log.add_message(targeting_item.item.targeting_message)

            if targeting_cancelled:
                game_state = previous_game_state

                message_log.add_message(Message('Targeting cancelled'))

            if xp:
                leveled_up = player.level.add_xp(xp)
                message_log.add_message(
                    Message('You gain {0} experience points.'.format(xp)))

                if leveled_up:
                    message_log.add_message(
                        Message(
                            'Your battle skills grow stronger! You reached level {0}'
                            .format(player.level.current_level) + '!',
                            libtcod.yellow))
                    previous_game_state = game_state
                    game_state = GameStates.LEVEL_UP

        if game_state == GameStates.ENEMY_TURN or game_state == game_state.CLICK_MOVE:

            # before anybody takes their turn
            player_eot = player.fighter.EndofTurn()
            process_turn(player, player_eot, message_log)

            for entity in entities:
                if entity.ai:

                    enemy_turn_results = entity.ai.take_turn(
                        player, fov_map, game_map, entities)
                    process_turn(player, enemy_turn_results, message_log)

                    # Manage conditions and end of turn effects
                    if entity.fighter:
                        enemy_turn_results = entity.fighter.EndofTurn()

                    process_turn(player, enemy_turn_results, message_log)

                    if game_state == GameStates.PLAYER_DEAD:
                        break

            else:
                if game_state != game_state.CLICK_MOVE:
                    game_state = GameStates.PLAYERS_TURN
Exemplo n.º 44
0
def main():
    constants = get_constants()

    # libtcod.console_set_custom_font('consolas_unicode_16x16.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    # libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_set_custom_font(
        'terminal16x16_gs_ro.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)

    libtcod.console_init_root(constants['screen_width'],
                              constants['screen_height'],
                              constants['window_title'], False)

    con = libtcod.console_new(constants['screen_width'],
                              constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'],
                                constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    libtcod.sys_set_fps(24)

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, constants)

            show_main_menu = True