JavaScript- Text Based Adventure Game 1

Over the last few days I have been working on a text based adventure game written in JavaScript. I learnt how to do this on the codeacademy website:

http://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/6?curriculum_id=506324b3a7dffd00020bf661

This is what the program looks like when running my adventure game:

game 1

If you follow the above link it should take you straight to the part of the tutorial where you build your own game. You may need to select lesson 6/6 from the drop-down arrow on the left hand side, inside the white side panel.

If you want to you can follow this linkΒ to copy and paste my code from there into the simulator found at the previous link:

https://drive.google.com/file/d/0B6y9ITteBcqLVV9fbFZlTUg5T28/view?usp=sharing

Hopefully you will enjoy playing this text based rpg style game. Its the longest piece of code I’v written so far but the story-lines are not even 2 minutes long.

You will notice this post is entitled ‘JavaScript- Text Based Adventure Game 1’. This is because I have been trying to insert this code file into a html file for it run on the browser and I cannot figure it out! I think my coding is wrong somewhere but I do not know anything about HTML so I’m not too disappointed. Once I crack this enigma (and maybe one of you will know how I can do it) then I will post a second post linking straight to the html site where the game can be played!

game
A print-screen of the code in notebook++

Any thoughts on how to make this better, more fun, or just if you can help me out with inserting it into a html file that works in the browser would be amazing and greatly appreciated! πŸ™‚ πŸ™‚ have fun πŸ™‚ πŸ™‚

9 comments

  1. Hi!

    I run the script in Firefox 38.0.5’s console. In case you wanna see what I got:

    KNIGHT
    CHAPEL
    NO
    ——————————————–
    >undefined
    “The priest names you as a coward. You have not acted like a knight. Your adventure is over”
    ——————————————–

    KNIGHT
    CHAPEL
    YES
    NO
    ———————————–
    >undefined
    “The priest names you as a coward and you are disgraced”
    ———————————–

    KNIGHT
    CHAPEL
    YES
    YES
    3 (not have a torch)
    NO
    ———————————–
    >undefined
    ———————————–

    KNIGHT
    CHAPEL
    YES
    YES
    3 (not have a torch)
    YES
    SWORD
    3
    ———————————–
    >undefined
    ———————————–

    Liked by 1 person

  2. Hi thank you so much I’m glad you tried it out, you got more results than me lol i get a blank screen in IE, Chrome and with Firefox all I can see is the text lmao πŸ™‚ also the first results are correct the second are errors in my code πŸ™‚ πŸ™‚ darn coding πŸ™‚ πŸ™‚

    Liked by 1 person

    • Wow thank you so much πŸ™‚ πŸ™‚ I don’t have time to edit my code at the moment but I will and will post an update when it is fully complete πŸ™‚ Thanks again for doing that πŸ™‚ πŸ™‚

      Like

Leave a comment