Making a text-based adventure game with Ruby

Started by
8 comments, last by evillive2 8 years, 9 months ago

I want to make a text-based adventure game using only Ruby. I have no idea of what direction to go in. Pleas help me. Thanks!

Advertisement

Google has quite a bit to say on the topic: ruby text-based adventure game programming

There are links to several tutorials and examples there.

Google has quite a bit to say on the topic: ruby text-based adventure game programming

There are links to several tutorials and examples there.

This is the most useless things there is to say.

Google is not a magic answer to every question every new person has.

I just googled that, the first three results are not tutorials and the first two are not helpful at all.

The first result is this very thread.

The second one is reddit learnprogramming, a thread about text game, nothing to do with Ruby.

The third result is github repo of a ready Ruby text game.

The fourth is an actual tutorial, which may or may not be good, I don't know. I don't know Ruby so I can't tell.

This brings us to: Google tutorials can be very wrong.

I just googled the most infamous question: "php sql tutorial".

The first result is a Polish website (I'm Polish), a tutorial that is over 10 years old.

It's well written, split in pages, explains everything so even if you didn't know PHP you'd understand it.

...and it contains this as an example (if you don't know PHP, this allows for SQL injection and is hilariously unsafe and I could nuke or steal your database with just a few get request if you shipped that code):


$id=$_GET['id'];
//... - NO CHECKING, ESCAPING OR SANITIZING HERE
$query=" SELECT * FROM contacts WHERE id='$id'";

The happy coincidence that I got a result in my native language brings us to: Google is highly personalized.

Google changes. Your browsing habits, websites falling and rising in popularity, other people following the links, your location - these all have impact.

At these point I can't even google common words: if I google 'gawk' I get GNU hits (GNU version of awk tool), if I google 'kate', I get KDE hits (their text editor is Kate).

Most people don't get GNU and KDE results at the top. We get a lot of results for topics we browse and google a lot.

Google is hilariously unfit for broad general questions because it varies too much, you'd never get that bad PHP tutorial as first hit if you are not Polish. Actually, you'd probably get my next results, which were not too bad, and were in English - just because we are in different countries, I get an SQL injection tutorial and you get a proper one. Both of us walks away with an answer, except mine is broken, I wasted my time reading it and I will later have to waste more time unlearning it.

The fact that you have a good answer at the top of your google search doesn't mean that the next person will too, if it means anything, it means you browse good websites or got lucky.

The entire point of having a forum with post scores is so that the knowledge is in one and easy to find place, doesn't get lost over time and if someone says something stupid they get -5 on their post and the harmful answer is rendered completely inert. Everyone can judge that a +5 post is good and -5 one is bad. Not everyone can judge "obvious" flaws in code written in language they are just learning. The PHP SQL example is extreme and almost a straw man, but it's 2015 and people still make obvious mistakes like that.


This is the most useless things there is to say.

I'd say a one page post that does nothing but chastise another poster and derail the topic is much more useless than one that actually addresses the OP's question...

This isn't helping anyone. Please get back on topic.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

I want to make a text-based adventure game using only Ruby. I have no idea of what direction to go in. Pleas help me. Thanks!

From the post above, it looks like you don't know Ruby. Is this a personal challenge, or is there some other reason that you need to use Ruby?

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

The reason i would like to use ruby is that it seems so much more simple than javascript or numerous other languages. however,i would take any language as a solution to my problem. as long as the end result is a text based adventure game then i'm happy. and to answer your question i am a bit of a noob when it comes to code so i don't know ruby,but at the start it came more naturally than JS.

Well, there's two broadly divergent paths to that goal.

Using a large, feature-rich, well-defined suite of tools that are purpose-built for creating text adventures, so that all you have to provide is location, prose, and story; tools such as http://inform7.com/

Or, writing the top loop, command interpreter, state engine, output renderer, and persistence systems yourself, all while also writing the game that uses them. The good news is, you can tackle those one at a time, and the interpreter doesn't initially have to be more complex than "command = in.readLine().trim()", to grossly oversimplify things.

I'm afraid most of the "tutorials" I can find for the latter were either written in the 90s or written for CLI PHP... and I wouldn't inflict either of those on a masochist even if they asked me nicely. I'd suggest instead taking in a number of "make a text adventure" tutorials only for their structure; don't copy their code, and ignore their choice of programming language, just follow along their design decisions and re-write those in your own favourite language.

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

To be honest Ruby has a lot of very powerful string handling / mangling functions so may be a good candidate for writing a text adventure but, then so do a lot of other languages.

The best way to begin if you want to stick with Ruby would be to download a copy of why's (poignant) Guide to Ruby:

http://mislav.uniqpath.com/poignant-guide/

Start working your way through it and then do some experimentation. Simple text adventures are one of the ways a lot of us first learned programming as you can build more and

more complexity into your text adventure the more you learn. e.g...

Start with output and display a prompt
Learn some input and reply to the prompt
Learn to loop and implement two way responses
Learn array so you can build a command list and inventory system.

You aren't going to find a complete build your own text adventure using Ruby. You are going to have to learn the language and then work your way through making the text adventure through trial and error. One of the advantages of Ruby is there is a huge community around the language so if you join a few Ruby forums there will be tons of people willing to give you help and advice.

If you get stuck you could google around for old BASIC adventure game programming books from the c64, ZX Spectrum era as they may have some useful information.

There are countless codebases (not many good for tutorial purposes) for text based MUDs on the interwebs. They were super popular in the early 90s and some had rebuilds in the 2000s in languages like perl and python that are probably much more relevant to what you are looking for.

The point is many are still actually active and I would recommend playing a few to get ideas on what you want to accomplish in terms of differentiating you game from existing ones. For the most part one can get away with renaming things in the area files as a start and fiddling with existing code to see how it affects the rest of the game.
Evillive2

This topic is closed to new replies.

Advertisement