Giter Club home page Giter Club logo

javascript-text-adventure-demo's Introduction

JavaScript Adventure Demo

When I was a kid, I loved text adventure games like Adventure and Zork. I tried to make my own with languages like Perl and Python, but never managed to succeed. I always told myself that if I could figure it out, I'd be a real programmer. Well, I've been learning JavaScript lately and while I was driving one day, how such a program could work popped into my head. The result is the JavaScript you see here in adventure.js.

So I'm sharing it here on GitHub so other aspiring programmers can study it, learn from it, and modify it to create the text adventure game of their dreams.

How to Run

Probably the best way is in the Chrome developer console or as a snippet. You also could probably run it from the command line with Node with the right extension, but vanilla Node doesn't like the prompt() function. JavaScript is admittedly the worst language to write this sort of thing in, but it's what I have.

Adapt it to Your Own Ends

The code is absurdly documented and should be highly modular. You can add as many rooms, items, locked doors, and other things as you like.

Some things you could do to improve this game:

  • Add torch items, torch mechanics, and rooms that are dark and unlit by default.
  • Make the item properties for the rooms arrays so a room can contain more than one item.
  • Add enemies to fight, as well as fight mechanics and player hitpoints.
  • Create an actual win condition for the game so you don't have to enter the "quit" command.
  • Create a scoring system of some sort.

Have fun! Let me know if you make anything cool with this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.