text adventure
woooooo
by mrcrazypants987
HTML
<title>TEXT GAME</title>
<p id=roomnum>0</p>
<body>
<form onSubmit="go();return false;">
<input id="input-textbox" type="text" autocomplete="off" />
<input type="submit" />
</form>
<textarea id="output-textbox" rows="20" cols="50" readonly></textarea>
<br><input type="color" id="color chooser"><br>
<p>after chosing a color type text color</p>
<script>
var room = 0;
var key = false;
var inventory = [];
textIn = document.getElementById("input-textbox");
textOut = document.getElementById("output-textbox");
function process(input) {
if (input == "hi") {
return "hello";
} else if (input == "start") {
room = 1;
document.getElementById("roomnum").innerHTML = room;;
return "you wake up in a empty room"
} else if (input == "help") {
return "possible commands include:search,"
}
//search command<
else if (input == "search") {
if (room == 1) {
key = true;
inventory.push("key");
return "you find a key on the floor"
} else {
return "you have to start the game"
}
}
//search command>
// Customization<
else if (input == "textcolor") {
var colorx = document.getElementById("color chooser").value;
document.getElementById("output-textbox").style.color = colorx;
return "you have chosen a color"
}
// Customization>
//door opening code<
else if (input == "open door") {
if (room == 1) {
if (key == true) {
room = 2;
document.getElementById("roomnum").innerHTML = room;
return "the door opens"
} else {
return "the door is locked"
}
} else {
return "there is no door"
}
}
//door opening code>
//inventory command<
//inventory command>
// default response<
else {
...