Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - KM

Pages: [1]
Programming / Re: Screen Not Refreshing upon Menu Close
« on: February 05, 2017, 10:54:47 AM »
1.6.0, I believe.  The full .rar for the project I'm working on is here;

The goal is once I have the basic engine off the ground to work towards creating Robert E. Howard's Conan universe as a roguelike.  I'm setting it before the history of Conan, but I'd like it to be a very low-fantasy game with little magic, no leveling up, no health bars, etc.

It's pretty ambitious considering this is the first thing I've programmed past "hello world" and some GML applications, but there it is.

Thanks a lot, btw, Ava, really appreciate the help.  Still trying to wrap my head around a lot of Python.

Programming / Re: Screen Not Refreshing upon Menu Close
« on: February 05, 2017, 08:31:00 AM »
Thanks Avagart, but I tried what you suggested and it didn't fix it.

I don't think those lines actually fix the display like I want, they were just shots in the dark from me.

I don't understand why moving refreshes the screen, I thought it would just be fov_recompute =True under line 769, but putting that in anywhere else doesn't seem to have the same effect.

As for having the 'player moved' prompt, it's either because I was working towards having it be turn based when an enemy is in fov, or because the code is cobbled together from various places, I can't really remember which.

I just don't understand why it is drawing the actors regardless, yet the background tiles aren't being drawn upon leaving any kind of menu.

Thanks regardless; I've removed the vestigial 'player moved' notations.

Programming / Re: Screen Not Refreshing upon Menu Close
« on: February 04, 2017, 08:09:48 AM »
Ah, that makes more sense, lol.

Entire code on pastebin:

Programming / Re: Screen Not Refreshing upon Menu Close
« on: January 29, 2017, 06:18:47 AM »
Passlain seems to be down; and I've never used github before.  I'll have to look into it.

Programming / Screen Not Refreshing upon Menu Close
« on: January 28, 2017, 10:39:39 PM »
I've been struggling lately with having my screen refresh upon the inventory or level-up menu being closed.  I'm going to put relevant parts of script here, any help is appreciated.  Other minor bugs;
1.  The screen, upon resizing, doesn't resize any of the menu bars to make them fit the new window size that bearlibterminal imparts.
2.  I'd like to be able to display names with just a mouse hover, rather than a mouse click, mouse-click I'd like to work into having a more full description come up.  Not sure where or if there are commands for these things.

def inventory_menu(header):
    global fov_recompute
    #show a menu with each item of the inventory as an option
    if len(inventory) == 0:
        options = ['Inventory is empty.']
        options = []
        for item in inventory:
            text =
            #show additional info, in case it's equipped
            if and
                text = text + ' (on ' + + ')'
        #options = [ for item in inventory]
    index = menu(header, options, INVENTORY_WIDTH)
    #if an item was chosen, return it
    if index is None or len(inventory) == 0: return None
    return inventory[index].item

    terminal.clear_area(0, 0, MAP_WIDTH, MAP_HEIGHT)
    fov_recompute = True

def handle_keys():
    global fov_recompute
    # Read keyboard input
    global key

    key =
    if key == terminal.TK_ESCAPE:
        # Close terminal
        return 'exit'
    if game_state == 'playing':
        #??? it was 'exit()'
        a = 'player moved'
        if key == terminal.TK_KP_2 or key == terminal.TK_DOWN:
            player_move_or_attack(0, 1)
            return a
        elif key == terminal.TK_KP_8 or key == terminal.TK_UP:
            player_move_or_attack(0, -1)
            return a
        elif key == terminal.TK_KP_6 or key == terminal.TK_RIGHT:
            player_move_or_attack(1, 0)
            return a
        elif key == terminal.TK_KP_4 or key == terminal.TK_LEFT:
            player_move_or_attack(-1, 0)
            return a
        elif key == terminal.TK_KP_7:
            player_move_or_attack(-1, -1)
            return a
        elif key == terminal.TK_KP_9:
            player_move_or_attack(1, -1)
            return a
        elif key == terminal.TK_KP_1:
            player_move_or_attack(-1, 1)
            return a
        elif key == terminal.TK_KP_3:
            player_move_or_attack(1, 1)
            return a
        elif key == terminal.TK_KP_5:
            return a
        else: #test for other keys
            if key == terminal.TK_G:
                #pick up an item
                for object in objects:  #look for an item in the player's tile
                    if object.x == player.x and object.y == player.y and object.item:

            if key == terminal.TK_I:
                #show the inventory; if an item is selected, use it
                chosen_item = inventory_menu('Press the key next to an item to use it, or any other to cancel.\n')
                if chosen_item is not None:

            if key == terminal.TK_D:
                #show the inventory; if an item is selected, drop it
                chosen_item = inventory_menu('Press the key next to an item to drop it, or any other to cancel.\n')
                if chosen_item is not None:

            if key == terminal.TK_C:
                #show character info
                level_up_xp = LEVEL_UP_BASE + player.level * LEVEL_UP_FACTOR
                msgbox('Character Information\n\nLevel: ' + str(player.level) +
                       '\nExperience: ' + str(player.fighter.xp) + ' / ' + str(level_up_xp) +
                       '\n\nMaximum HP: ' + str(player.fighter.max_hp) +
                    '\nAttack: ' + str(player.fighter.power) + '\nDefense: ' + str(player.fighter.defense), CHARACTER_SCREEN_WIDTH)

            if key == terminal.TK_SHIFT:
                key =
                if key == terminal.TK_PERIOD and stairs.x == player.x and stairs.y == player.y:
                    #go down stairs, if the player is on them
         key =
         if key == terminal.TK_RESIZED:
            new_columns = terminal.state(terminal.TK_WIDTH)
            new_rows = terminal.state(terminal.TK_HEIGHT)

    return 'didnt-take-turn'

This is typically what makes me lose interest in Python; I can never get all the dependencies right.  I'm not able to pip anything; what should a folder with this working contain?

Nevermind, thanks Cfyz, I've got it working again. 

So I downloaded the new bearlibterminal after seeing your comment in my thread, and now when I import it, I'm getting strange errors. 
Now when I try to run my program I get;

Code: [Select]
Traceback (most recent call last):
  File "", line 6, in <module>
    import PyBearLibTerminal as bear
  File "C:\Python27\Grit\", line 70, in <module>
    _wprint = _library.terminal_print16
  File "C:\Python27\lib\ctypes\", line 375, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python27\lib\ctypes\", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'terminal_print16' not found

I have no idea what this means, or why your code looks like this.

Programming / Re: Packaging a python script as an executable
« on: January 19, 2017, 02:25:38 AM »
If you thought you'd just compile Python into an EXE then you've fundamentally misunderstood the whole premise of it.


Programming / Re: Packaging a python script as an executable
« on: January 18, 2017, 02:21:59 AM »
Java is super annoying dependency, because it's such a bloatware and security risk. Python is also kind of dumb, because it has no backwards compatibility whatsoever so many programs simply include the entire python with it, using the proper version for that software. Why can't we fix this? It's 2017 and still we don't have something that would turn EVERYTHING into a native .exe (binary) without dependencies. Go computer science.

It's actually baffling to me how difficult this process is.  I figured I'd just hit compile in Python and BOOM, have an .exe.

Alas, it's a challenge.

Programming / Packaging a python script as an executable
« on: January 17, 2017, 04:11:41 AM »
Hi; I'm trying to package my python script as an executable, but am finding it very difficult.  I'm following the directions at, and am using bearlibterminal and libtcod, and am getting dependencies that I don't understand how to fix.  When I try to click the .exe file I created, it just crashes with no errors, but it runs fine when I launch it out of powershell.

Here's what powershell tells me when I'm trying to run the .exe from there:

Code: [Select]
PS C:\Python27\Grit\dist> .\gritandsteel.exe
Traceback (most recent call last):
  File "", line 6, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "PyBearLibTerminal.pyc", line 58, in <module>
  File "PyBearLibTerminal.pyc", line 56, in _load_library
RuntimeError: BearLibTerminal library cannot be loaded (looked for BearLibTerminal.dll in C:\Python27\Grit\dist\gritandsteel.exe)
PS C:\Python27\Grit\dist>

I don't know why it's looking for the .dll IN the .exe, or how I would fix it.  BearLibTerminal.dll is in the same file directory as my .exe.

I created the .exe using the tutorial code here:
Code: [Select]
from distutils.core import setup
import py2exe
import os
import sys
# The filename of the script you use to start your program.
target_file = ''
# The root directory containing your assets, libraries, etc.
assets_dir = '.\\'
# Filetypes not to be included in the above.
excluded_file_types = ['py','pyc','project','pydevproject']
def get_data_files(base_dir, target_dir, list=[]):
    " * get_data_files
    " *    base_dir:    The full path to the current working directory.
    " *    target_dir:  The directory of assets to include.
    " *    list:        Current list of assets. Used for recursion.
    " *
    " *    returns:     A list of relative and full path pairs. This is
    " *                 specified by distutils.
    for file in os.listdir(base_dir + target_dir):
        full_path = base_dir + target_dir + file
        if os.path.isdir(full_path):
            get_data_files(base_dir, target_dir + file + '\\', list)
        elif os.path.isfile(full_path):
            if (len(file.split('.')) == 2 and file.split('.')[1] not in excluded_file_types):
                list.append((target_dir, [full_path]))
    return list
# The directory of assets to include.
my_files = get_data_files(sys.path[0] + '\\', assets_dir)
# Build a dictionary of the options we want.
opts = { 'py2exe': {
                    'includes' : ['anydbm', 'dbhash'],
# Run the setup utility.

Any help is appreciated as to why this isn't launching.  Thank you.

Quote from: KM
however the whole screen goes black while it's being resized, and only upon movement does it render the screen again.  Is this normal?
Does it go black while resizing or after you release the mouse button and until some other input? The latter is normal since scene contents are cleared when it is resized, you need to recalculate the layout and redraw the scene for a new size.

Before another input is entered.  Would I be able to make it recalculate and redraw the layout based on releasing the mouse button or somesuch?

Is there a general command to redraw the screen, as I'm also having the same issues after exiting any other screen such as inventory, character class, and etc, that only the objects and items are drawn before I move, not the background tiles at all.

Thanks a lot, Cfyz!

So I have it working as per your first example with variable cell sizes; however the whole screen goes black while it's being resized, and only upon movement does it render the screen again.  Is this normal?

Hi; perhaps this is the wrong place for this, but..

I'm done the roguelike tutorial, and I've ported it all into the bearlibterminal for the graphical aspect.  I am simply wondering how to make my window resizeable?

I read the documentation, but it's not working and I don't know why.  Example code plz?

Pages: [1]