48 KiB
Modules
- Tile :
Object
- Colors :
Object
- SOLVED :
number
- MINE :
number
- SECTOR_SIZE :
number
- DIFFICULTY :
number
- CENTRAL_AREA_DIFFICULTY_MODIFIER :
number
- DETAIL_THRESHOLD :
number
- DRAG_THRESHOLD :
number
- MAX_TRIES :
number
- ANIMATION_SPEED_BASE :
number
- CANVAS_ID :
string
- EventBus
- EventHandler
- GameController
- GameLogic
- GameRenderer
- Saver
- SipHash
- LZW
- UIRenderer ⇐
GameRenderer
- DataHasher :
object
An object with methods
hash
andgenerate_key
such thathash(key, data)
returns a number between 0 and 1 (deterministically), andgenerate_key(seed)
returns an approprite key forhash
- DataCompressor :
object
An object with methods
zip
andunzip
that accept/return strings and are reversable- LOOPS :
object
An object with common loops used in game.
- convert ⇒
Array.<number>
Converts between tile and sector coordinates.
- isMine ⇒
boolean
Get the type of a tile (mine or not) deterministically.
Members
- game :
GameController
The game controller instance.
Events
Tile : Object
Properties
Name | Type | Description |
---|---|---|
LOST | number |
Tile is lost |
HIDDEN | number |
Tile is hidden |
FLAGGED | number |
Tile is flagged |
REVEALED | number |
Tile is revealed |
Colors : Object
Properties
Name | Type | Description |
---|---|---|
BACKGROUND | string |
Background color |
BACKGROUND_ZOOMED | string |
Background color when zoomed |
TILE_DEFAULT | string |
Default tile color |
TILE_CLICKABLE | string |
Tile color when it is clickable |
TILE_REVEALED_NUMBERED | string |
Tile color when it is revealed and has a number |
TILE_REVEALED_EMPTY | string |
Tile color when it is revealed and is empty |
TILE_FLAGGED | string |
Tile color when it is flagged |
SECTOR_OVERLAY | string |
Sector overlay color |
SECTOR_LOST_OVERLAY | string |
Lost sector overlay color |
SECTOR_BORDER | string |
Sector border color |
FLAG_PARTICLE_COLOR | string |
Flag particle color |
SOLVED_PARTICLE_COLOR | string |
Solved particle color |
LOST_PARTICLE_COLOR | string |
Lost particle color |
SOLVED : number
MINE : number
SECTOR_SIZE : number
DIFFICULTY : number
CENTRAL_AREA_DIFFICULTY_MODIFIER : number
DETAIL_THRESHOLD : number
DRAG_THRESHOLD : number
MAX_TRIES : number
ANIMATION_SPEED_BASE : number
CANVAS_ID : string
EventBus
Access: public
EventBus~constructor()
Initializes the event bus
Kind: inner method of EventBus
EventBus~on(event, callback)
Sets up an event listener
Kind: inner method of EventBus
Param | Type | Description |
---|---|---|
event | string |
Event name |
callback | function |
Callback function to call (multiple functions can be added) |
EventBus~emit(event, ...args)
Emits an event
Kind: inner method of EventBus
Param | Type | Description |
---|---|---|
event | string |
Event name |
...args | * |
Arguments to pass to the callback functions (0 or more) |
EventBus~onRetrievable(event, callback)
Sets up a retrievable event listener
Kind: inner method of EventBus
Param | Type | Description |
---|---|---|
event | string |
Event name |
callback | function |
Callback function to call (can only be used once) |
EventBus~get(event, ...args) ⇒ any
| undefined
Retrieves data from an event
Kind: inner method of EventBus
Returns: any
| undefined
- - Data from the event or undefined
Param | Type | Description |
---|---|---|
event | string |
Event name |
...args | * |
Arguments to pass to the callback function (only one) |
EventHandler
Access: public
EventHandler~constructor(canvas, bus)
Initializes the event handler
Kind: inner method of EventHandler
Param | Type |
---|---|
canvas | HTMLCanvasElement |
bus | EventBus |
"mousedown"
Kind: event emitted by EventHandler
"mousemove"
Kind: event emitted by EventHandler
Emits: EventBus#event:drag - optionally
"mouseup"
Kind: event emitted by EventHandler
Emits: EventBus#event:click - optionally
, EventBus#event:clean_cache - optionally
"mouseleave"
Kind: event emitted by EventHandler
Emits: EventBus#event:clean_cache - optionally
"wheel"
Kind: event emitted by EventHandler
Emits: EventBus#event:zoom
, EventBus#event:clean_cache
"click"
Kind: event emitted by EventHandler
"contextmenu"
Kind: event emitted by EventHandler
"resize"
Kind: event emitted by EventHandler
Emits: EventBus#event:resize
"beforeunload"
Kind: event emitted by EventHandler
Emits: EventBus#event:save
"visibilitychange"
Kind: event emitted by EventHandler
Emits: EventBus#event:save - optionally
GameController
Access: public
- GameController
- instance
- inner
- ~constructor(seed)
- ~init()
- ~loadImage() ⇒
Promise.<void>
- ~start(tries)
- ~reset(tries)
gameController.seed : string
- Seed for the game (by default a stringified 16 digit random number)
Kind: instance property of GameController
gameController.key : Uint32Array
Kind: instance property of GameController
GameController~constructor(seed)
Initializes the game controller
Kind: inner method of GameController
Param | Type | Description |
---|---|---|
seed | string |
Seed for the game |
GameController~init()
Initializes the game
Kind: inner method of GameController
GameController~loadImage() ⇒ Promise.<void>
Loads the game image
Kind: inner method of GameController
Returns: Promise.<void>
- - Promise that resolves when the image is loaded
Throws:
Error
- If the image fails to load
GameController~start(tries)
Starts the game
Kind: inner method of GameController
Emits: EventBus#event:start
Param | Type | Description |
---|---|---|
tries | number |
Number of times the game has been reset |
GameController~reset(tries)
Resets the game
Kind: inner method of GameController
Param | Type | Description |
---|---|---|
tries | number |
Number of times the game has been reset |
GameLogic
Access: public
- GameLogic
- instance
- .start_time :
Date
- .start_time :
- inner
- ~constructor(game_pos, key, bus)
- ~timeAndStats() ⇒
Object
- ~setStats(stats)
- ~click(x, y, button)
- ~updateKey(key)
- ~buy(x, y, [s_x], [s_y])
- ~reveal(x, y, [s_x], [s_y], [no_animate]) ⇒
Promise.<boolean>
- ~flag(x, y, [s_x], [s_y])
- ~isClickable(x, y, [s_x], [s_y]) ⇒
boolean
- ~isFlagged(x, y, [s_x], [s_y]) ⇒
boolean
- ~isRevealed(x, y, [s_x], [s_y]) ⇒
boolean
- ~isSectorSolved(sector_key) ⇒
boolean
- ~collectStats(s_x, s_y)
- ~flagCount(x, y, [s_x], [s_y]) ⇒
number
- ~mineCount(x, y, [s_x], [s_y], [force]) ⇒
number
- ~buildSector(s_x, s_y) ⇒
Array.<Array.<Array.<number>>>
- ~buildSectorCache(s_x, s_y) ⇒
Array.<Array.<Array.<number>>>
|false
- ~cleanSectorCache()
- ~animate(key, type, is_tile, [duration])
- instance
gameLogic.start_time : Date
Kind: instance property of GameLogic
GameLogic~constructor(game_pos, key, bus)
Initializes the game logic
Kind: inner method of GameLogic
Param | Type |
---|---|
game_pos | Object |
key | Uint32Array |
bus | EventBus |
GameLogic~timeAndStats() ⇒ Object
Returns the current time in seconds
Kind: inner method of GameLogic
Returns: Object
- - Time and stats
GameLogic~setStats(stats)
Sets the stats
Kind: inner method of GameLogic
Param | Type | Description |
---|---|---|
stats | Object |
Stats from the save |
GameLogic~click(x, y, button)
Handles a click
Kind: inner method of GameLogic
Emits: EventBus#event:click_convert
, EventBus#event:is_buy_button
Param | Type | Description |
---|---|---|
x | number |
X-coordinate in terms of screen |
y | number |
Y-coordinate in terms of screen |
button | number |
0 for left, 1 for middle, 2 for right (from Event#button) |
GameLogic~updateKey(key)
Updates the game key
Kind: inner method of GameLogic
Param | Type |
---|---|
key | Uint32Array |
GameLogic~buy(x, y, [s_x], [s_y])
Buys a sector
Kind: inner method of GameLogic
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~reveal(x, y, [s_x], [s_y], [no_animate]) ⇒ Promise.<boolean>
Reveals a tile
Kind: inner method of GameLogic
Returns: Promise.<boolean>
- - Resolves to whether the reveal caused more
than one tile to be revealed
Param | Type | Default | Description |
---|---|---|---|
x | number |
X-coordinate of tile | |
y | number |
Y-coordinate of tile | |
[s_x] | number |
X-coordinate of sector if x is relative |
|
[s_y] | number |
Y-coordinate of sector if y is relative |
|
[no_animate] | boolean |
false |
If true, no animation will be played |
GameLogic~flag(x, y, [s_x], [s_y])
Flags a tile
Kind: inner method of GameLogic
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~isClickable(x, y, [s_x], [s_y]) ⇒ boolean
Checks if a tile is clickable
Kind: inner method of GameLogic
Returns: boolean
- - True if tile is clickable, false otherwise
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~isFlagged(x, y, [s_x], [s_y]) ⇒ boolean
Checks if a tile is flagged
Kind: inner method of GameLogic
Returns: boolean
- - True if tile is flagged, false otherwise
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~isRevealed(x, y, [s_x], [s_y]) ⇒ boolean
Checks if a tile is revealed
Kind: inner method of GameLogic
Returns: boolean
- - True if tile is revealed, false otherwise
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~isSectorSolved(sector_key) ⇒ boolean
Checks if a sector is solved
Kind: inner method of GameLogic
Returns: boolean
- - True if sector is solved, false otherwise
Param | Type | Description |
---|---|---|
sector_key | string |
Key of sector |
GameLogic~collectStats(s_x, s_y)
Collects statistics about a solved sector into the stats object
Kind: inner method of GameLogic
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameLogic~flagCount(x, y, [s_x], [s_y]) ⇒ number
Counts the number of flags adjacent to a tile
Kind: inner method of GameLogic
Returns: number
- - The number of flags adjacent to the tile
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
GameLogic~mineCount(x, y, [s_x], [s_y], [force]) ⇒ number
Counts the number of mines adjacent to a tile
Kind: inner method of GameLogic
Returns: number
- - The number of mines adjacent to the tile
Param | Type | Default | Description |
---|---|---|---|
x | number |
X-coordinate of tile | |
y | number |
Y-coordinate of tile | |
[s_x] | number |
X-coordinate of sector if x is relative |
|
[s_y] | number |
Y-coordinate of sector if y is relative |
|
[force] | boolean |
false |
Force count even if tile is revealed |
GameLogic~buildSector(s_x, s_y) ⇒ Array.<Array.<Array.<number>>>
Builds a new sector
Kind: inner method of GameLogic
Returns: Array.<Array.<Array.<number>>>
- - The sector
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameLogic~buildSectorCache(s_x, s_y) ⇒ Array.<Array.<Array.<number>>>
| false
Builds a sector cache
Kind: inner method of GameLogic
Returns: Array.<Array.<Array.<number>>>
| false
- - The cached sector
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameLogic~cleanSectorCache()
Cleans the sector cache
Kind: inner method of GameLogic
Emits: EventBus#event:sector_bounds
GameLogic~animate(key, type, is_tile, [duration])
Animate a tile or sector
Kind: inner method of GameLogic
Param | Type | Default | Description |
---|---|---|---|
key | string |
Key to use for hashing | |
type | string |
Type of animation | |
is_tile | boolean |
Whether the animation is for a tile | |
[duration] | number |
ANIMATION_SPEED_BASE |
Duration of the animation if it is a tile (in ms). |
GameRenderer
Access: public
- GameRenderer
- instance
- inner
- ~constructor(img, game_pos, key, bus)
- ~getViewPos() ⇒
Object
- ~setViewPos(view_pos)
- ~draw()
- ~drawBuyButtons(s_x, s_y)
- ~drawRoundedRect(x, y, width, height, radius)
- ~drawStaticTiles(sector, s_x, s_y, x, y)
- ~drawAnimatedTiles(sector, s_x, s_y, x, y)
- ~drawParticles(tile_x, tile_y, frame_time, [color])
- ~drawSectorBorders(start_x, start_y)
- ~drawSectorOverlays(s_x, s_y)
- ~drawSolvedAnimations(s_x, s_y)
- ~drawSolvedParticles(sector_x_pos, sector_y_pos, frame_time)
- ~drawLostAnimations(s_x, s_y)
gameRenderer.canvas : HTMLCanvasElement
Kind: instance property of GameRenderer
gameRenderer.ctx : CanvasRenderingContext2D
Kind: instance property of GameRenderer
GameRenderer~constructor(img, game_pos, key, bus)
Initializes the game renderer
Kind: inner method of GameRenderer
Param | Type |
---|---|
img | Image |
game_pos | Object |
key | Uint32Array |
bus | EventBus |
GameRenderer~getViewPos() ⇒ Object
Returns the current view position (for saving)
Kind: inner method of GameRenderer
Returns: Object
- - The view position (offset, tile_size)
GameRenderer~setViewPos(view_pos)
Sets the view position (from saved data)
Kind: inner method of GameRenderer
Emits: EventBus#event:disable_click - optionally
Param | Type | Description |
---|---|---|
view_pos | Object |
The view position (offset, tile_size) |
GameRenderer~draw()
Draws the main game frame
Kind: inner method of GameRenderer
GameRenderer~drawBuyButtons(s_x, s_y)
Draws the buy buttons for a sector
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameRenderer~drawRoundedRect(x, y, width, height, radius)
Draws a rounded rectangle
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of top-left corner |
y | number |
Y-coordinate of top-left corner |
width | number |
Width of rectangle |
height | number |
Height of rectangle |
radius | number |
Radius of rounded corners |
GameRenderer~drawStaticTiles(sector, s_x, s_y, x, y)
Draws a static tile
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
sector | Array.<Array.<Array.<number>>> | false |
|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
GameRenderer~drawAnimatedTiles(sector, s_x, s_y, x, y)
Draws an animated tile
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
sector | Array.<Array.<Array.<number>>> | false |
|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
GameRenderer~drawParticles(tile_x, tile_y, frame_time, [color])
Draws particles
Kind: inner method of GameRenderer
Param | Type | Default | Description |
---|---|---|---|
tile_x | number |
X-coordinate of top-left corner of tile | |
tile_y | number |
Y-coordinate of top-left corner of tile | |
frame_time | number |
Time since animation start (0-1) | |
[color] | string |
"COLORS.FLAG_PARTICLE_COLOR" |
Color of particle |
GameRenderer~drawSectorBorders(start_x, start_y)
Draws sector borders
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
start_x | number |
X-coordinate of top-left corner of sector |
start_y | number |
Y-coordinate of top-left corner of sector |
GameRenderer~drawSectorOverlays(s_x, s_y)
Draws sector overlays
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameRenderer~drawSolvedAnimations(s_x, s_y)
Draws solved sector animations
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
GameRenderer~drawSolvedParticles(sector_x_pos, sector_y_pos, frame_time)
Draws solved sector particles
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
sector_x_pos | number |
X-coordinate of sector |
sector_y_pos | number |
Y-coordinate of sector |
frame_time | number |
Current frame time (0-1) |
GameRenderer~drawLostAnimations(s_x, s_y)
Draws lost sector animations
Kind: inner method of GameRenderer
Param | Type | Description |
---|---|---|
s_x | number |
X-coordinate of sector |
s_y | number |
Y-coordinate of sector |
Saver
Access: public
- Saver
- instance
- .save_interval_id :
number
- .save_interval_id :
- inner
- instance
saver.save_interval_id : number
- ID of the autosave interval
Kind: instance property of Saver
Saver~constructor(game, bus)
Initializes the game saver
Kind: inner method of Saver
Param | Type |
---|---|
game | GameController |
bus | EventBus |
Saver~startAutosaver()
Starts the autosave feature
Kind: inner method of Saver
Saver~stopAutosaver()
Stops the autosave feature
Kind: inner method of Saver
Saver~isSaved() ⇒ boolean
Checks if a save exists
Kind: inner method of Saver
Returns: boolean
- - Whether a save exists or not
Saver~save() ⇒ string
Saves the game data
Kind: inner method of Saver
Returns: string
- - Compressed game data
Emits: EventBus#event:view_pos
, EventBus#event:time_and_stats
Saver~load([compressed])
Loads the game data
Kind: inner method of Saver
Emits: EventBus#event:set_stats
, EventBus#event:set_view_pos
, EventBus#event:update_key
, EventBus#event:reset
Param | Type | Description |
---|---|---|
[compressed] | string |
Compressed game data |
Saver~saveToFile()
Saves the game data to a file
Kind: inner method of Saver
Saver~deleteSave()
Deletes the save
Kind: inner method of Saver
Saver~loadFromFile()
Loads the game data from a file
Kind: inner method of Saver
SipHash
Access: package
Important: - Siphash implementation taken from https://github.com/jedisct1/siphash-js (minified browser version)
Author: Frank Denis
LZW
UIRenderer ⇐ GameRenderer
Extends: GameRenderer
Access: public
- UIRenderer ⇐
GameRenderer
- instance
- inner
- ~constructor(img, game_pos, key, bus)
- ~loop()
- ~drag(x, y)
- ~resize()
- ~updateKey(key)
- ~zoom(x, y, is_zoom_in) ⇒
boolean
- ~isBuyButton(x, y) ⇒
boolean
- ~sectorBounds() ⇒
Array
- ~clickConvert(x, y) ⇒
Array
uiRenderer.loop : function
- Bound
loop
function sorequestAnimationFrame
keepsthis
context
Kind: instance property of UIRenderer
uiRenderer.frame_id : number
- ID of the animation frame
Kind: instance property of UIRenderer
UIRenderer~constructor(img, game_pos, key, bus)
Initializes the renderer
Kind: inner method of UIRenderer
Param | Type |
---|---|
img | Image |
game_pos | Object |
key | Uint32Array |
bus | EventBus |
UIRenderer~loop()
Loops the animation frame and calls draw
Kind: inner method of UIRenderer
UIRenderer~drag(x, y)
Updates the offset
Kind: inner method of UIRenderer
Param | Type | Description |
---|---|---|
x | number |
X-offset |
y | number |
Y-offset |
UIRenderer~resize()
Resizes the canvas
Kind: inner method of UIRenderer
UIRenderer~updateKey(key)
Updates the key
Kind: inner method of UIRenderer
Param | Type |
---|---|
key | Uint32Array |
UIRenderer~zoom(x, y, is_zoom_in) ⇒ boolean
Zooms in or out
Kind: inner method of UIRenderer
Returns: boolean
- - True if details are hidden, false otherwise
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of center of zoom |
y | number |
Y-coordinate of center of zoom |
is_zoom_in | boolean |
True if zooming in, false if zooming out |
UIRenderer~isBuyButton(x, y) ⇒ boolean
Checks if the tile is a buy button
Kind: inner method of UIRenderer
Returns: boolean
- True if the tile is a buy button, false otherwise
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of the tile |
y | number |
Y-coordinate of the tile |
UIRenderer~sectorBounds() ⇒ Array
Returns the sector bounds
Kind: inner method of UIRenderer
Returns: Array
- - Array of [start_x, start_y, end_x, end_y]
UIRenderer~clickConvert(x, y) ⇒ Array
Converts raw click coords to sector adjusted coords
Kind: inner method of UIRenderer
Returns: Array
- - Array of [x, y]
Param | Type | Description |
---|---|---|
x | number |
X-coordinate of the click |
y | number |
Y-coordinate of the click |
DataHasher : object
An object with methods hash
and generate_key
such that hash(key, data)
returns a number between 0 and 1 (deterministically),
and generate_key(seed)
returns an approprite key for hash
Access: public
Properties
Name | Type |
---|---|
generate_key | function |
hash | function |
- DataHasher :
object
- ~generate_key(seed) ⇒
Uint32Array
- ~hash(key, data) ⇒
number
- ~generate_key(seed) ⇒
DataHasher~generate_key(seed) ⇒ Uint32Array
Generates a key
Kind: inner method of DataHasher
Returns: Uint32Array
- - Generated key
It can be the input itself for hashing
functions that dont require keys.
Param | Type | Description |
---|---|---|
seed | string |
Seed for the hash function |
DataHasher~hash(key, data) ⇒ number
Hashes data
Kind: inner method of DataHasher
Returns: number
- - Psudo-random number between 0 and 1
Param | Type | Description |
---|---|---|
key | Uint32Array |
Key for the hash function For hashing functions that dont require keys it can be concatenated to the data |
data | string |
Data to hash |
DataCompressor : object
An object with methods zip
and unzip
that accept/return strings and are reversable
Access: public
Properties
Name | Type |
---|---|
zip | function |
unzip | function |
- DataCompressor :
object
- ~zip(data) ⇒
string
- ~unzip(data) ⇒
string
- ~zip(data) ⇒
DataCompressor~zip(data) ⇒ string
Compresses data
Kind: inner method of DataCompressor
Returns: string
- - Compressed data
Param | Type | Description |
---|---|---|
data | string |
Uncompressed data |
DataCompressor~unzip(data) ⇒ string
Uncompresses data
Kind: inner method of DataCompressor
Returns: string
- - Uncompressed data
Throws:
Error
- If the compressed data is invalid
Param | Type | Description |
---|---|---|
data | string |
Compressed data |
LOOPS : object
An object with common loops used in game.
Access: public
Properties
Name | Type |
---|---|
overAdjacent | function |
overAdjacentSum | function |
anyAdjacent | function |
overOnScreenSectors | function |
overTilesInSector | function |
anyTilesInSector | function |
overTilesInSectorSum | function |
- LOOPS :
object
- ~overAdjacent(f, x, y, [s_x], [s_y])
- ~overAdjacentSum(condition, x, y, [s_x], [s_y]) ⇒
number
- ~anyAdjacent(condition, x, y, [s_x], [s_y]) ⇒
boolean
- ~overOnScreenSectors(f, start_x, start_y, sector_size_in_px, canvas)
- ~overTilesInSector(f)
- ~anyTilesInSector(condition) ⇒
boolean
- ~overTilesInSectorSum(condition) ⇒
number
LOOPS~overAdjacent(f, x, y, [s_x], [s_y])
Loops over adjacent tiles and calls a function
Kind: inner method of LOOPS
Param | Type | Description |
---|---|---|
f | function |
Function to call on each tile |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
LOOPS~overAdjacentSum(condition, x, y, [s_x], [s_y]) ⇒ number
Loops over adjacent tiles and checks if they satisfy a condition
Kind: inner method of LOOPS
Returns: number
- - Number of adjacent tiles that satisfy the condition
Param | Type | Description |
---|---|---|
condition | function |
The condition to check |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
LOOPS~anyAdjacent(condition, x, y, [s_x], [s_y]) ⇒ boolean
Loops over adjacent tiles and checks if they satisfy a condition
Kind: inner method of LOOPS
Returns: boolean
- - Whether any adjacent tile satisfies the condition or not
Param | Type | Description |
---|---|---|
condition | function |
The condition to check |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
LOOPS~overOnScreenSectors(f, start_x, start_y, sector_size_in_px, canvas)
Loops over all sectors in view
Kind: inner method of LOOPS
Param | Type | Description |
---|---|---|
f | function |
Function to call on each sector |
start_x | number |
X-coordinate of starting sector |
start_y | number |
Y-coordinate of starting sector |
sector_size_in_px | number |
Size of sector in pixels |
canvas | HTMLCanvasElement |
Canvas element |
LOOPS~overTilesInSector(f)
Loops over all tiles in a sector
Kind: inner method of LOOPS
Param | Type | Description |
---|---|---|
f | function |
Function to call on each tile |
LOOPS~anyTilesInSector(condition) ⇒ boolean
Checks if any tile in a sector satisfies a condition
Kind: inner method of LOOPS
Returns: boolean
- - Whether any tile satisfies the condition or not
Param | Type | Description |
---|---|---|
condition | function |
The condition to check |
LOOPS~overTilesInSectorSum(condition) ⇒ number
Checks if all tiles in a sector satisfy a condition
Kind: inner method of LOOPS
Returns: number
- - Number of tiles that satisfy the condition
Param | Type | Description |
---|---|---|
condition | function |
The condition to check |
convert ⇒ Array.<number>
Converts between tile and sector coordinates.
Returns: Array.<number>
- - An array containing resultant coords
Param | Type | Description |
---|---|---|
to_local_coords | boolean |
Whether to convert to local coordinates or not |
x | number |
X-coordinate of tile |
y | number |
Y-coordinate of tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
isMine ⇒ boolean
Get the type of a tile (mine or not) deterministically.
Returns: boolean
- - Whether the tile is a mine or not
Param | Type | Description |
---|---|---|
key | string |
Key to use for hashing |
x | number |
X-coordinate of the tile |
y | number |
Y-coordinate of the tile |
[s_x] | number |
X-coordinate of sector if x is relative |
[s_y] | number |
Y-coordinate of sector if y is relative |
game : GameController
The game controller instance.
Kind: global variable
Access: public
"DOMContentLoaded"
Kind: event emitted