Attempt two: request for feedback on adventure game

Attempt two: request for feedback on adventure game
0

#1

This is an incomplete app. I am wondering why document.getElement doesn’t change text. Does text only change once function is completely done? Console.logs show up so why not the doc( etc.)s?

Here is link. https://github.com/fmd123/Algorithms_Exercises/blob/master/workshop2.html
Any insight would be gratefully accepted.

I’ve messed with it some more but it seems to only show the new text after the function is complete. Is my observation accurate?


#2

This isn’t an answer to your question, but if you want to make text adventure games, I would heartily recommend Inform7. It is the most interesting programming language I have ever come across (it is designed to mirror natural English) and it’s sole purpose is for creating text adventures!

It is so much fun!


#3

Hi :slight_smile:

I really don’t understand your code, with comments it would be more readable.

I create a pen in codepen:

// http://codepen.io/erretres/pen/GqLZvW

I don’t understand (the problem), when I click the button “Let’s begin!” change to “Start Room” (document.getElementById() is working, is changing the text:)

 document.getElementById("dialogue").innerHTML = "Start Room";

The rest of the code:


var answer;
var room;
var shield;		
	function start(){
		console.log ("startroom");
		
		answer = prompt("You are in a room with a door to the north and a door to the south. Which way do you want to go?");
		document.getElementById("dialogue").innerHTML = "Start Room";
			if (answer === "go north"){
				document.getElementById("dialogue").innerHTML = "Dragon Room";
				dragon();
				
			} else if (answer === "go west"){
				document.getElementById("dialogue").innerHTML = "west Room";
				west();
				
			} else if (answer === "go east"){
				answer = prompt("you can't go east. Which way do you want to go?");
			} else if (answer === "go south"){
				answer = prompt("you can't go south. Which way do you want to go?");
			} else if (answer === "quit") {
				document.getElementById('dialogue').innerHTML = "bye!";
				return;
			} else {
				answer = prompt("Please choose from available answers. Which way do you want to go?");
			}
	}
	function dragon(){
		console.log ("dragon room");
		answer = prompt("There is a dragon here. What do you want to do?");
		if (answer === "quit");
		document.getElementById("dialogue").innerHTML = "Too late, you were eaten.";
		return;
	}
	function west() {
		console.log ("westroom");
		document.getElementById("dialogue").innerHTML = "west Room";
		answer = prompt("You are in a room with a shield. What do you want to do?");
	}
$(document).ready(function(){
		    $("#begin").click(function(){
		        start();
		    });
	});