script main.js - numberZero/CrocoLogic GitHub Wiki

Classes

Meat

See Meat

Crocodile

See Crocodile

Cell (private)

Functions

forEachCell

  1. void forEachCell(function cb)

Applies cb to every cell of the battlefield. If cb throws exception, it will be passed to the caller immediately, and loop execution won’t be continued.

forEachCrocodile

  1. void forEachCell(function cb)

Applies cb to every Crocodile on the battlefield. If cb throws exception, it will be passed to the caller immediately, and loop execution won’t be continued.

play

  1. void play(void)

Resumes game execution. No call counting performed; one play() is enough after many pause(), and vice-versa.

pause

  1. void pause(void)

Pauses game execution. No call counting performed; one ause() is enough after many play(), and vice-versa.

initialize

  1. void initialize(void)
  2. void initialize(integer mapSize)
  3. void initialize(integer mapWidth, integer mapHeight)

Deletes battlefield (if any) with all objects and makes a new one with given size (in the first form, current size is kept).

serialize

  1. object serialize(void)

Saves map to plain (convertible to JSON) object and returns it.

restore

  1. void serialize(object data)

Loads map from object returned by serialize (possibly converted to and from JSON)

_Die

  1. _Die.call(obj)
  2. obj.die() — this form is preferred

Private function used in Crocodile and Meat prototypes. Deletes object it is applied to.

_GlobalUpdate

_GlobalUpdate(void)

Updates whole battlefield.

_GlobalStep

_GlobalStep(void)

Updates animation and, if needed, calls _GlobalUpdate.