Skip to content
This repository has been archived by the owner on Oct 18, 2019. It is now read-only.

Commit

Permalink
Added JSDoc strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuno-Ki committed Sep 13, 2018
1 parent 63b5b55 commit 45c74e0
Show file tree
Hide file tree
Showing 43 changed files with 1,056 additions and 29 deletions.
11 changes: 11 additions & 0 deletions .jsdoc.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": ["plugins/markdown"],
"templates": {
"systemName": "An Offline Life",
"theme": "cosmo",
"navType": "vertical",
"inverseNav": true,
"syntaxTheme": "dark",
"search": false
}
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ It makes use of the following works:
* [Rollup][rollup] - without it I wouldn't have been able to piece together everything.
* [Terser][terser] by [Fábio Santos][terser-creator] - it optimises the heck out of your code!

## Documentation

After cloning the repo and installing the deps, run `npm run doc` and look
into the new `docs` directory.

## Known Issues

If you are starting this app with a file: protocol under a Chromium-based
Expand Down
150 changes: 150 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "rollup -c",
"check-filesize": "node scripts/check-filesize.js",
"doc": "jsdoc -d ./docs -p ./package.json -R README.md src",
"doc": "jsdoc -c .jsdoc.conf.json -d ./docs -p ./package.json -R README.md -t ./node_modules/ink-docstrap/template -r src",
"lint": "npm run lint:css && npm run lint:js",
"lint:css": "csscomb src/*.css",
"lint:js": "standard src/*.js",
Expand Down Expand Up @@ -37,6 +37,7 @@
"gh-pages": "1.2.0",
"html-minifier": "3.5.20",
"http-server": "0.11.1",
"ink-docstrap": "1.3.2",
"jsdoc": "3.5.5",
"pug": "2.0.3",
"rollup": "0.65.0",
Expand Down
14 changes: 14 additions & 0 deletions src/alias.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
/**
* Kontra is a small game engine written for JS13kGames contests.
*
* @external kontra
* @see {@link https://straker.github.io/kontra/|kontra}
*/

/**
* In order to save some bytes, alias the global kontra object.
*
* @name k
* @global
* @alias kontra
*/
window.k = window.kontra
65 changes: 45 additions & 20 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
/**
* Defines constants used on several places in this game.
* However, since they are keys, they won't get minified.
* I'm sorry for the unreadable names, but they are saving bytes...
*
* @namespace
* @type object
* @property { object } constants - Holding different values for the game.
* @property { string } constants.a - Basename of the sound file.
* @property { string } constants.ae - Filename of the sound file.
* @property { string } constants.g - Name of the ground layer used for tiles.
* @property { string } constants.t - Basename of the tileset file.
* @property { string } constants.te - Filename of the tileset file.
* @property { number } constants.h - Height of a tile in px.
* @property { number } constants.w - Width of a tile in px.
* @property { number } constants.r - Number of tiles in a row of the canvas.
* @property { number } constants.c - Number of tiles in a col of the canvas.
* @property { number } constants.u - ID of the tile not in the tileset.
* @property { number } constants.m - ID of the modem tile.
* @property { number } constants.p - ID of the pc tile with wire to top.
* @property { number } constants.b1 - 1st ID of button/switch tile (active).
* @property { number } constants.b2 - 2nd ID of button/switch tile (neutral).
* @property { number } constants.b3 - 3rd ID of button/switch tile (inactive).
* @property { number } constants.s1 - 1st ID of server tile (pos ok, num ok).
* @property { number } constants.s2 - 2nd ID of server tile (pos ok, num nok).
* @property { number } constants.s3 - 3rd ID of server tile (pos nok, num nok).
*/
const constants = {
// Assets
a: 'd', // audio (dial-up)
ae: 'd.mp3', // audio with extension
g: 'g', // ground layer
t: 't', // tileset
te: 't.png', // tileset with extension
a: 'd',
ae: 'd.mp3',
g: 'g',
t: 't',
te: 't.png',

// World
h: 32, // height of a tile
w: 32, // width of a tile
r: 9, // tiles in a row
c: 9, // riles in a column
h: 32,
w: 32,
r: 9,
c: 9,

u: 0, // unset tile id
m: 16, // modem id
p: 12, // personal computer id
b1: 13, // button in active position
b2: 14, // button in neutral position
b3: 15, // button in deactive position
s1: 9, // server with correct position and value
s2: 10, // server with correct position, but wrong value
s3: 11 // server with neither correct position nor value
u: 0,
m: 16,
p: 12,
b1: 13,
b2: 14,
b3: 15,
s1: 9,
s2: 10,
s3: 11
}

export default constants
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const gameLoopOptions = {
update
}

/**
* Starts the game.
*
* @requires module:render
* @requires module:update
* @requires module:loadAssets
*/
loadAssets().then(() => {
k.init()

Expand Down
18 changes: 18 additions & 0 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ import factory from './sprites/factory'
import store from './store'
import tilesets from './tilesets'

/**
* Renders the game every frame.
*
* @module render
* @exports render
* @requires constants
* @requires module:sprites/factory
* @requires module:store
* @requires module:tilesets
*/

/**
* Delegates the rendering to specialised methods.
* Creates some transparent sprites for click handling.
*
* @public
* @function
*/
const render = function () {
const { gm } = store.state()
const tiles = tilesets()
Expand Down
Loading

0 comments on commit 45c74e0

Please sign in to comment.