init
This commit is contained in:
commit
6b926e53bf
19 changed files with 1365 additions and 0 deletions
27
js/state.js
Normal file
27
js/state.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Controls a block's state of matter.
|
||||
*/
|
||||
|
||||
function state(event, state, temperature, isMin) {
|
||||
if (event.type != 'tick') return;
|
||||
|
||||
let cx = event.data[0];
|
||||
let cy = event.data[1];
|
||||
let chunks = event.canvas;
|
||||
|
||||
let temp = chunks.getBlock(cx, cy, true);
|
||||
|
||||
if (chunks.noTick[cx*chunks.height + cy]) return;
|
||||
|
||||
if ((temp > temperature) == isMin) {
|
||||
chunks.setBlock(cx, cy, mainTiles.resolveID(state[0],state[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Tile.prototype.state = function ( state2, temperature, isMin) {
|
||||
this.interactions.push(function (event) {
|
||||
state(event, state2, temperature, isMin)
|
||||
});
|
||||
return this;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue