script main.js - numberZero/CrocoLogic GitHub Wiki
Classes
Meat
See Meat
Crocodile
See Crocodile
Cell (private)
Functions
forEachCell
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
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
void play(void)
Resumes game execution. No call counting performed; one play()
is enough after many pause()
, and vice-versa.
pause
void pause(void)
Pauses game execution. No call counting performed; one ause()
is enough after many play()
, and vice-versa.
initialize
void initialize(void)
void initialize(integer mapSize)
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
object serialize(void)
Saves map to plain (convertible to JSON) object and returns it.
restore
void serialize(object data)
Loads map from object returned by serialize (possibly converted to and from JSON)
_Die
_Die.call(obj)
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.