Sign in to follow this  

Make a Text game on HTML

Recommended Posts

Hello, and welcome to the forum.

Most important thing is to get coding. Just get something up there on the screen in your browser and then keep working forward.

Your first challenge is just working out how to get a simple message on the screen, this is the start of your text-based RPG and can be as simple as throwing an element in an HTML document and firing it in to your browser.

Next challenge would be accepting some user input. So throw an input field on there.

Now things get trickier. Work out how to get user inputted text out of that input field, you'll need to use that. This is a bit trickier but there is loads of information out there so get researching (get good at finding good information, MDN should be a first stop).

Now that you know how to get user input and display some things on the screen its time to react to the user input. So you work out how to setup a handler that listens for the Enter key, when the user presses this you get the text out of the input field and work out what to do next. You probably want some conditional logic so a series of `if` statement could help, maybe even a `switch` (when you get really good there are some design patterns that can help you here), this is actually the start of your input handler code.

By now you actually have a game of sorts, you've displayed a message to the user, gathered user input and reacted to that user input, this is 90% of most games. You are also starting to have a bit more code now so you'll want to start researching and thinking about different ways you can structure your code to make things easier for you.

Where will you stick variables? Do you have any variables that affect your conditional logic when handling user input? If so, how do you make it available?

The most important thing is to get coding.

Don't get swayed by the 5000 JS frameworks and libraries out there, yes, lots of them will be useful to you, but its easy to get lost as JS is a very thriving language. Keep to the basics, learn how JS works, learn how it interacts with CSS and HTML, learn how to fire up a local server to get stuff in to the browser, none of these things are particularly trivial so take your time, do you research, and write lots and lots and lots of code, doesn't matter if most of it is crap, learn why its crap and how you can improve on it, even after 20 years of coding you'll still look back on some of the code you wrote last week/month and know that you could do it better, or learn (or remember!) a technique that would have helped.

The most important thing is to get coding.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.