When I got a trollish email saying that JavaScript is not part of HTML5, which is only true on the most purest level, I decided to create a simple game using only HTML. A number of the tags that HTML5 added are clearly designed for use with a scripting language so to utilize HTML5 you really need to utilize a scripting language. Now if the email was complaining about WebGL, I would not have considered it a troll but still hope that Microsoft does start supporting it (as the rumours suggest).
The first problem that needs to be overcome when creating a no-script HTML game is finding a game that is simple enough to implement using only the markup language. This essentially means that the game needs to be representable using static pages with the interactive element switching between pages. While this is a huge restriction, I actually came up with a number of games that could be created using a number of static pages. These include 3D mazes, path choosing adventure games, combination puzzles, restricted move games such as Tower of Hanoi, and many of the various NIM style math games. Obviously I chose NIM.
The game must be broken into a number of pages. If we go with the traditional 17 objects, then we will need 17 pages for the player landing zones. The problem is that the computer needs to make a move. There are at least two ways to deal with this. The obvious solution is to add an additional 16 pages for the computer moves. When you think about it, the only thing that happens during the computer move is that the number of objects it is going to take is revealed so the only thing the player is doing is clicking to continue. While merging the computer results with the landing page adds a slight bit of complexity, it cuts the number of pages necessary in half.
The easiest way of implementing the game is to create the 17 item page, clone it, remove an item and repeat until all 17 pages have been created. A slightly faster, though more complex way of doing this would be to write a script to generate the pages for you. Each page simply consists of images and links to the lower-numbered three pages so this is really simple to create. That really is all there is to it. Sorry for boring you this week.
No comments:
Post a Comment