tstand90 / roguelike_tutorial_revised Goto Github PK
View Code? Open in Web Editor NEWThe python libtcod roguelike tutorial, with good coding practices kept in mind from the beginning.
The python libtcod roguelike tutorial, with good coding practices kept in mind from the beginning.
[deleted]
causing a crash when the confuse spell expires.
Hi,
First up - FREAKING AWESOME TUTORIAL!!!! THANK YOU SO MUCH!!! - seriously the BEST roguelike tute I've encountered.
I think that part 10 of the tutorial (http://rogueliketutorials.com/tutorials/tcod/part-10/) incorrectly includes the file type suffix in two places within data_loaders.py - specifically in save_game for the call to write out the data, and also in load_game for the call to read in the data.
I believe that this is because Python automatically appends the ".dat" to those calls, whereas in the filesystem check to verify the save file the ".dat" is required.
You have corrected this in the GitHub repo but not in the tutorial text which could throw folks (it confused me :) )
Thanks again!
Roguebasin has a walkthrough for setting up on Windows: http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python3%2Blibtcod,_setup_Windows
Will there be similar set-up page for this tutorial?
As the title says, the Shelve code didn't work for me. It created files named "savedgame.dat" and appended the extension ".dat" to the end, so I had "savedgame.dat.dat". This wouldn't load.
I was able to fix this by following the code found here and creating my own "savegames" folder.
Would it be possible for you to add an update where you use/incorporate a pre-defined room or map as one of the levels?
For some reason I am really struggling with getting a statically built or pre-defined map to render properly
Hi, I'm new to Python and following along with your tutorial.
Page 1 says to make a file input_handlers but it needs to be input_handlers.py
Obviously most will figure it out, but you should probably update that.
You state
In order to follow along with this tutorial, you'll need to follow the instructions on that site for setting up Python and libtcod (Part 1 up until the code starts).
I think you should replace that with actual (simple) directions.
roguelike
directory and change to that folder. mkdir roguelike && cd roguelike
git clone https://github.com/libtcod/python-tcod.git
arial10x10.png
from python-tcod/fonts/libtcod/
into your directory. cp python-tcod/fonts/libtcod/arial10x10.png .
libtcodpy.py
from python-tcod
into your directory. cp python-tcod/libtcodpy.py .
libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
If I'm reading the libtcod Python source correctly this says blit from console con to console root (0). This will work since, at least at this point in time, you con is also the root console. But this won't work if the con is any other console. So this may break if the users try to reuse this with more than one console in the future.
When talking about key input there is a 'catures' instead of 'captures'
The Python 3.7 linter throws an error message complaining that:
Instance of 'Fighter' has no 'owner' member
and
Instance of 'BasicMonster' has no 'owner' member
It's a minor issue, and doesn't affect the actual operation of the code (i.e. it still works), but it's a bit of an annoyance. I'd propose that the following lines be added to the top of those two files in order to quiet the error:
# This prevents the linter from complaining that the component class has no owner member (it's defined in the entity class init)
# pylint: disable=no-member
Thanks for the tutorial series @TStand90!
Came here from the current summer 2019 "roguelike tutorial" threads.
I'm quite new to python, but wanted to point out to anyone else experiencing an issue with
python3 engine.py
on Win10 to try deleting the libtcodpy
folder that ships with this codebase.
Once I did that, everything ran properly.
When Enum is first introduced, the tutorial suggests using auto() if using Python 3.6+. Likewise, literal string interpolation should be suggested as a 3.6+ alternative to string.format() when the message system is first implemented.
Running engine.py results in : TypeError: make_map() takes 6 positional arguments but 7 were given.
Snip :
game_map = GameMap(map_width, map_height)
game_map.make_map(max_rooms, room_min_size, room_max_size, map_width, map_height, player)
The Esper.py library seems fairly popular on r/roguelikedev. But there is no explicit tutorial for it. Would be great to integrate it with a version of this tutorial and introduce the concept of an Entity-Component-System as well.
It seems that loading a save doesnt work. Im not sure of the exact cause. Will dig through the code.
In Part 1 we removed using default 0
console and instead of it declared con
.
But there are code snippets in Part 2 which says that we do still use the default one also:
- libtcod.console_put_char(con, player_x, player_y, ' ', libtcod.BKGND_NONE)
- libtcod.console_put_char(0, player_x, player_y, ' ', libtcod.BKGND_NONE)
+ libtcod.console_put_char(con, player.x, player.y, ' ', libtcod.BKGND_NONE)
+ libtcod.console_put_char(0, player.x, player.y, ' ', libtcod.BKGND_NONE)
So what is right version?
Hey there,
Fantastic tutorial! I've used it to build a little tdl game and am now trying to follow the same sequence to build a roguelike in the Godot engine. It would be helpful to have an index page or for the menu to contain a description of what each step.
For example:
Part 1
could change to
Part 1 - Drawing and Moving @
It would also make it easier to find where someone left off when coming back after a break from coding.
At the end, where we use our defined console instead of the default one (0
), there is this line of code and not a single word about it:
libtcod.console_put_char(con, player_x, player_y, ' ', libtcod.BKGND_NONE)
Even after it is marked not as new but the modified line, there is no word about its previous version neither.
I understand that it clears old @
from the console, but since I am a newbie I can't figure out why it just simply doesn't erase also the current @
? It has the same coordinates after all!
Hi! Thank you so much for this great tutorial! I've been learning a lot and really enjoying it!
I had a problem halfway in Chapter 8 getting an error because it said a positional argument was missing from the function call for inventory_menu. This function call is located within the render_all function's definition, the following lines:
if game_state == GameStates.SHOW_INVENTORY:
inventory_menu(con, 'Press the key next to an item to use it, or Esc to cancel.\n',
player.inventory, 50, screen_width, screen_height)
It's missing an argument for the root console. I believe it should read as this, instead:
if game_state == GameStates.SHOW_INVENTORY:
inventory_menu(con, root_console, 'Press the key next to an item to use it, or Esc to cancel.\n',
player.inventory, 50, screen_width, screen_height)
I should note that this error is in the tutorial on http://rogueliketutorials.com/tdl/8. I figured this was a good way to contact you. I don't have a Reddit account, actually. I assume that it's not in GitHub code. Thanks!!!
Hey guys,
I kept getting a crash as the results of used items were compacted into a list string from using extend instead of in append for the results of an item_use_results. Changing the results.extend to results.append fixed the issue
+ def use(self, item_entity, **kwargs):
+ results = []
+
+ item_component = item_entity.item
+
+ if item_component.use_function is None:
+ results.append({'message': Message('The {0} cannot be used'.format(item_entity.name), libtcod.yellow)})
+ else:
+ kwargs = {**item_component.function_kwargs, **kwargs}
+ item_use_results = item_component.use_function(self.owner, **kwargs)
+
+ for item_use_result in item_use_results:
+ if item_use_result.get('consumed'):
+ self.remove_item(item_entity)
+
>>>> results.extend(item_use_results) <- Should be RESULTS.APPEND
+
+ return results
+
+ def remove_item(self, item):
+ self.items.remove(item)
Hello,
I was following your tutorial (thanks a lot for it) and I've noticed that the code in part 3 is not generating a map and this is due to the fact that there's an iteration on an empty list which, for what I understood, python simply skips it.
Details:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.