I am kind of new to programming and learning the basics. My knowledge in programming in JavaScript is not the best but i'm trying :)
I am trying to code a very simple, adventure like, story text based HTML/JavaScript game. I have watched tutorials and read online on how to code my game. I have a few problems that I can't seem to figure out how to fix :(
Firstly, When the message comes up on the page and I minimize or go to another page, the message disappears and I have to refresh the page. I want it so it stays fixed on the page or have it in a modal pop up box thingy but don't know how to link my code to the modal box lol.
Secondly, When the user enters door 1, I want a story for that door, whereas, when the user types in door 2, I want the story to lead onto something else etc. Hope I have made sense lol xD I didn't want to come onto here and ask for help but I can't find any solutions :(
This is what I have done so far:
<!DOCTYPE html>
<html>
<head></head>
<body>
<script>
var choice = prompt("Door 1 or Door 2");
if (choice == "Door 1"){
confirm("Behind Door 1 is a dragon");
}
var choice2 = prompt("Do you want to attack or run?");
if (choice2 == "attack"){
confirm("You have killed the dragon");
} else {
(choice2 == "run")
confirm ("You have been burnt by the dragon");
}
var door = prompt ("The dragon was gaurding the treasure room, Do you wish to enter?");
if (door == "yes"){
confirm("You have entered the treasure room");
} else {
(door == "no")
confirm ("You have left the basement without the treasure!");
}
</script>
</body>
</html>
Thank you very much for taking time to read and the help :) appreciate it all!
Aucun commentaire:
Enregistrer un commentaire