DEV Community

loading...

I Want to Make A Text Adventure With ASCII Art - Any Hints Towards Libraries/Frameworks?

Peter
Python Developer digging PostgreSQL. Musician and Gamer when not coding.
・1 min read

Hi there! For quite some time I'm thinking about making a small text adventure, but I didn't want it to be text-only. A graphic novel is also something I don't want. Then I found the quite fascinating game Santuary RPG and I realized that such a reduced ASCII art style is something I would really like. I would like to do write the game in either Python or Rust.

Example

Now, whenever I google my way around the internet, I find a lot of pygame and Renpy references, but nothing convincing for Rust. And those two Python libs/frameworks seem to offer a bit too much. Now that I'm writing these lines, it occurs to me that I could adapt a simple terminal UI (TUI) framework for my purposes.

Should you happen to know a library that offers explicit support for story-supporting ascii art, please do let me know. :) And if you can recommend a simple TUI library, I'd also love to hear from you.

Cheers,
Peter

Discussion (2)

Collapse
ahferroin7 profile image
Austin S. Hemmelgarn

The be all end all for stuff like this is ncurses. It's the current iteration of what is one of the oldest TUI libraries in existence, and has bindings in almost every language imaginable. Python has native bindings for it in the curses module (technically, this will use whatever curses implementation is present on the system, which will usually be ncurses these days), and there appears to be at least one set of bindings for Rust. Most of the TUI related documentation you'll find online applies specifically to ncurses, or it's predecessor curses, as there really hasn't been much other than that made in this area.

ncurses, however, is really a generic TUI library. It does the art for typical UI stuff like dialogs and buttons, but doesn't support images. For that, you'd need to look at a different tool, though I don't have any suggestions for either Python or Rust for this (try searching 'python ASCII art' or 'rust ASCII art' in your search engine of choice).

Something else to consider though is that if you can get a sprite or tile-based library working, you can pre-generate sprites for all the characters you use and then use a simple grid system for displaying them. This would let you avoid the need for a terminal emulator and possibly do cool animations for things like scene transitions. You might want to look at SDL2 for this if you can't find other options, it's somewhat lower level than stuff like pygame, but there are still decent tutorials for it out there and it's trivially portable to most modern platforms.

Collapse
gadse profile image
Peter Author

Thanks for your input! I'll go with the curses module for the beginning, get the interface going and attack the ASCII art part when it gets relevant. The thing about not having to ship an integrated terminal emulator is quite compelling. :D