GithubHelp home page GithubHelp logo

tstand90 / roguelike_tutorial_revised Goto Github PK

View Code? Open in Web Editor NEW
97.0 12.0 27.0 1.02 MB

The python libtcod roguelike tutorial, with good coding practices kept in mind from the beginning.

Python 100.00%

roguelike_tutorial_revised's People

Contributors

tstand90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

roguelike_tutorial_revised's Issues

Python version 3.9.4(64-bit) make_map() in engine.py

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)

Table of Contents

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.

use static map as one of the levels

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

TDL tutorial Chapter 8 - Function call for inventory_menu missing arg

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!!!

Tutorial part 10 refers to incorrect filename in data_loaders.py

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!

subtle error in render_all part 2

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.

Using Shelve to save didn't work for me

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.

Python linter compains about components (Fighter, BasicMonster) not having 'owner' member

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

Part 8 - item.use - Extend called causing crash

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)

Loading a save is busted.

It seems that loading a save doesnt work. Im not sure of the exact cause. Will dig through the code.

Win10 - needed to delete `libtcodpy` folder

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.

Part 1 - Missing some code explanation

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!

Part 2 - Mismatch with previous Part

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?

Esper.py support in future version?

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.

setting up instructions + filenaming correction

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.

Setup

  1. Create a new roguelike directory and change to that folder. mkdir roguelike && cd roguelike
  2. Download python-tcod into this directory or git clone https://github.com/libtcod/python-tcod.git
  3. Copy arial10x10.png from python-tcod/fonts/libtcod/ into your directory. cp python-tcod/fonts/libtcod/arial10x10.png .
  4. Copy libtcodpy.py from python-tcod into your directory. cp python-tcod/libtcodpy.py .
  5. You're ready to begin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.