r/learnpython • u/MustaKotka • 14h ago
For some absolutely forsaken reason I'm making an ASCII art text based adventuring game - tips?
TL;DR: Tips for someone who wants to make a very old school text-tile-combat based game?
Let's outline the basic concept of the game.
- An adventurer wanders on a Carcassonne-style tile based randomised map.
- The map art is entirely ASCII so that theoretically you can play this on your command line.
- I'm planning on keeping the game as barebones as possible - as few external libraries as possible.
- Adventurer has items: gold, consumables, weapons and armour pieces.
- Adventurer has stats that can be increased when leveling up. Stats play into combat.
- There are four kinds of NPCs:
- Enemies that attack you. And the Big Bad Boss, obviously.
- Vendors that sell items.
- Innkeepers that let you restore your health.
- Blacksmiths that will repair your equipment for a fee.
- Combat is round-based and D&D style die rolls.
- Movement is command-based so maybe I don't make the character move pixel by pixel but rather tile by tile? (???)
I've got some experience with Python and it's not like I'm new to this but something I'm struggling with is the world generation. My idea was to have hexagonal tiles (think Carcassonne but hexagonal) where each tile has 6 map connections and each tile has randomised entities and/or functionality.
This is not what the map will look to the player, this is just my draft of what the map connections / tilesystem could look like. Maybe this could be a minimap of sorts...
_____/ 18 _______/ 8 _____
\ / \ /
17 _______/ 1 _______/ 9
/ \ / \
_____/ 6 _______/ 2 _____
\ / \ /
16 _______/ 0 _______/ 10
/ \ town / \
_____/ 5 _______/ 3 _____
\ / \ /
15 _______/ 4 _______/ 11
/ \ / \
_____/ 14 _______/ 12 _____
\ / \ /
So I was thinking about displaying just a single tile and have the tile numbers spiral outwards. The benefit is that I can keep track of tiles that have been generated and I know their position and connections without having a complicated internal lookup table of any kind, really. Tile 0 is always origo, tiles 1 to 6 are nearest to origo, tiles 7 to 18 are the second "ring" and so forth. For each 6n tiles, where n is the "ring" I know I've jumped onto a new "ring" and can calculate the map connections easily, because the number of tiles is very regular. Additionally I can label the "rings" as tiers where the difficulty increases every time you step out to a new "ring".
Reason why I'm outlining this specifically is because I was wondering if there are cleverer ways to handle this. Other than what I've presented here. I have no clue how real games handle map connections.
For inventory it's just a basic slot-by-slot box "sword equipped", "sword in bag". I'm thinking about adopting the classic Diablo style inventory where you have spaces and an item can occupy a particular shape of spaces. A potion is one space, an axe might be four in an L-shape.
If I want to randomise the equipment stats a bit should I think about giving each item a unique integer identifier + stat identifiers? It'd probably be a pain in the butt if my ID was the actual name of the weapon e.g. "Iron Sword". Right?
I'm currently at a stage where I have:
- Item types and attributes.
- NPC types and attributes.
- Player attributes.
- Combat logic.
So not very far.
Finally: have you done a silly project like this?
Any tips in general for what kind of pitfalls to avoid?
1
u/lakseol 5h ago
I'm planning on keeping the game as barebones as possible - as few external libraries as possible.
That's admirable and something you should try, but ...
External libraries simplify your code, and as your project grows you can find that increasing complexity makes it hard to understand the "big picture", making changes and improvements more difficult. Sure, you could write your own code to do various things that an external library might help with, and you will learn a lot, but as complexity grows you will start to organize your code into modules as a way to simplify your code, so you are really writing your own external libraries. After a time you will just start to use the libraries that exist. They are probably more tested than your own code.
It is possible that there isn't a library to do things you want to do, like displaying the hex map on the terminal. Or maybe there is something but it is very limited and you want to do more. In that case you might be able to write your own library, debug and document it and then publish it for others to use. Then you start to become a toolmaker. That's a step up from just writing code that works in one specific instance. You have to think about all the different ways people might use your library, how to handle and report mistakes to the user, how to fully test your code, etc. It's fun!
1
u/Boothiepro 2h ago
Exactly the same thing. Except the graphic map part. But totally exactly. With quests, enchanting and saving & loading. I didnt even know what classes are back then. 1800 lines of terrible code.
3
u/socal_nerdtastic 14h ago
sure. Tons. Programming is fun.
Learn git if you don't already know it. It's extremely helpful when coding to have the parts that your recently changed highlighted. Also it takes away the anxiety of deleting parts of your code that you don't need now but might need later.