koth-webplayer

Create A Game

Looking to make an online, javascript-based king-of-the-hill game? Great! Follow these steps to get going.

Fork this Project

The first thing you should do is fork this project so that you will have control over your own game.

Define your Game

The example game provided is a good starting point for making a game. You can begin by copying it:

Next you’ll want to configure the properties for your game. Open your newly created /<game_name>.htm file and change the meta values. There are descriptive comments throughout to help you.

Write your Code

At a minimum, all games need a GameManager, GameScorer and Display defined. You can see examples of all of these in the example folder you copied.

If you want more components, the structure is up to you, but it is recommended to add them in the components subdirectory. You may also want to define a stylesheet, which by convention is named style.css in the game’s folder, and referenced by the Display file (when defining the module dependencies you can include './style.css' to include the stylesheet).

The example files should provide some guidance on what needs to be written, but it may be helpful to have a high-level overview as well:

Test your Game

Once you have written some code, you can test it by opening your .htm file in a browser. Check the console for any errors encountered.

Until you have a question ID, the only way to get entries is to create them each time you open the game. Click “+ Add Entry” in the list on the left and paste in some test code. You can add as many entries as you need. Then you can “Begin Random Game” to see your game in action. Once you’re happy with the mechanics for a game, try “Begin Random Tournament” to see how it behaves when running as part of a full tournament (the tournament is configured by the meta tags in your HTML document).

Lint your Code

If you want to check your code for simple mistakes, you can add it to test.htm as a lint-module. Once you have done this, opening test.htm will run the linter against your code and warn you about any issues encountered. It is recommended that you fix these since some can lead to browser compatibility issues or subtle bugs. Others relate to code quality, and fixing them can make your code easier to work with in the future.

Release your Game

Once you’re happy with everything, post your game! This framework has built-in integration with the Stack Exchange network, so you can post a question on Programming Puzzles & Code Golf (but remember to test-drive it first on Meta!) then return to your /<game>.htm file and fill in the question ID so that it will automatically load answers.

Tag your question king-of-the-hill and javascript so that it will show up in this list.