Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to create a text-based game. As simple as that.

I have some understanding of the coding that needs to go into it as I do know a fair amount of JavaScript and I can do it in the JavaScript console in Google Chrome. But I would like to create a stand alone game that once it has been downloaded, that's it. It doesn't need a connection to the internet or anything. But I honestly don't have any idea on how to make a 'Start Screen' or anything like that.

Any links or guides that you guys have found/made to make text-based games would be grateful as all the things I've found have helped me in absolutely no way.

Sorry if this is the wrong website to ask this in, but it seems to be the best one for game dev. questions! ;)

share|improve this question

closed as off-topic by Anko, bummzack, msell, Nicol Bolas, Josh Petrie Jul 17 '13 at 13:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started" or "what should I learn next" cannot reasonably be answered with anything other than opinion polling and therefore are off topic for the site. For more information on how to ask a better question, see the help center" – Anko, bummzack, msell, Nicol Bolas, Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
If you're doing this as a project to learn to code then this won't be of help, but if you just want to make a text adventure that can be posted online or run localy go to textadenvtures.co.uk The Quest system is free and very powerful, (I recomend the tutorial though.) Plus you can extend it with Java! –  CLockeWork Jul 17 '13 at 8:45

1 Answer 1

up vote 3 down vote accepted

Short answer

Asking how to make a text-based game is essentially asking how to program. Learn to program.

Long version

Learn programming

Writing text-based games is a good way to learn.

This is the hard part. This is going to take time.

The first thing any game needs is a loop, input, output and something that converts input to output. This is what that would look like in Lua:

-- Process input into output
function process(i)
    if i == "hi" then return "Hi to you too, player." -- Player greets
    elseif i == "exit" then return -1 end             -- Player wants to quit

    -- ...add more cases here...

end

-- Main loop
while true do                     -- loop over these things
    local input = io.read()       -- read input
    local output = process(input) -- process it
    if output == -1 then          -- if it was a quit instruction
        os.exit()                 -- quit
    else
        print(output)             -- show output
    end
end
  1. Figure out what that is doing and why.

  2. When you realise you need state, look into variable assignment.

  3. When you realise you need collections of things like an inventory, look into data structures like arrays and lists.

  4. By then, you essentially know how to program.

Good luck!

For making a full game, you may want to write Python or JS instead. By the time you know how to program, it shouldn't matter much. Their syntax is very similar and the ideas always matter more than the syntax.

Same in JS

Since you know JS, here's a similar seed for a JS-based text adventure:

<html>
<head>
<title>Sample game</title>
</head>
<body>
<form onSubmit="go();return false;">
<input id="input-textbox" type="text" />
<input type="submit" />
</form>
<textarea id="output-textbox" rows="20" cols="50"></textarea>
<script>

textIn  = document.getElementById("input-textbox");
textOut = document.getElementById("output-textbox");

function process(input) {
    if (input == "hi") { return "Hi to you too, player."; }
    else if (input == "exit") { return "No."; }
}

function go() {
    var input = textIn.value;
    textIn.value = "";
    var output = process(input);
    textOut.value += output + "\n";
}

</script>
</body>
</html>

JSFiddle is handy for developing HTML/CSS/JS sketches and sharing them around. MDN and WebPlatform are my favourite web-dev resources.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.