Python libtcod on macosx

While I was preparing manual the post was deleted. But it's a pity just to delete it and probably someone else will need it in future. So here it is )

Posted Feb 9, 2016, 8:03 PM UTC · edited

83
droidenkoOP>_•

1.Need install dependency

For this:

Install Xcode

Install git!

I recommend install macports

From macports install libsdl2 and others. For example:

sudo port install libsdl2

2.Create directory for libtcod

mkdir libtcod-example cd libtcod-example

3.Download libtcod from github

git clone https://github.com/podiki/libtcod-mac.git

and

cd libtcod-mac

5.Run build libtcod

make -f makefiles/makefile-osx-sdl2 release

6.In libtcod-mac folder should be appear filse:

libtcod.a

libtcod.dylib

libtcodgui.a

libtcodgui.dylib

libtcodxx.a

libtcodxx.dylib

7.Create folder for your RL

8.Copy into RL folder files:

libtcod-mac/libtcod.a

libtcod-mac/libtcod.dylib

libtcod-mac/libtcodgui.a

libtcod-mac/libtcodgui.dylib

libtcod-mac/libtcodxx.a

libtcod-mac/libtcodxx.dylib

libtcod-mac/libtcod.cfg

libtcod-mac/data/fonts/arial10x10.png

libtcod-mac/python/libtcodpy.py

libtcod-mac/python/cprotos.py

9.Create the_best_rl.py file and insert code

import libtcodpy as libtcod

SCREEN_WIDTH = 80

SCREEN_HEIGHT = 50

LIMIT_FPS = 20

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

libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False)

libtcod.sys_set_fps(LIMIT_FPS)

libtcod.console_set_default_foreground(0, libtcod.white)

libtcod.console_put_char(0, 1, 1, '@', libtcod.BKGND_NONE)

libtcod.console_flush()

while not libtcod.console_is_window_closed():

key = libtcod.console_wait_for_keypress(True)

10.Run:

python the_best_rl.py

You should be seen black window with white @ in left-top corner

P.S. sorry for my English

7
rmtew•

English speakers could have easily provided less understandable instructions. Thanks for your effort.

2
TZero-t0•

Awesome, thank you so much man!

1