2020-04-27 01:38:20 +01:00
|
|
|
function randInt(min, max) {
|
|
|
|
min = Math.ceil(min);
|
|
|
|
max = Math.floor(max);
|
|
|
|
return Math.floor(Math.random() * (max - min)) + min;
|
|
|
|
}
|
|
|
|
|
|
|
|
const grassTiles = [0x8, 0x9, 0x10, 0x11];
|
|
|
|
|
|
|
|
// Porymap callback when a block is painted.
|
|
|
|
export function on_block_changed(x, y, prevBlock, newBlock) {
|
2020-04-30 02:41:19 +01:00
|
|
|
try {
|
2020-05-01 00:30:24 +01:00
|
|
|
// if (grassTiles.indexOf(newBlock.tile) != -1) {
|
|
|
|
// const i = randInt(0, grassTiles.length);
|
|
|
|
// map.setBlock(x, y, grassTiles[i], newBlock.collision, newBlock.elevation);
|
|
|
|
// }
|
|
|
|
console.log("ran", map.getWidth(), map.getHeight());
|
2020-04-30 02:41:19 +01:00
|
|
|
} catch(err) {
|
|
|
|
console.log(err);
|
2020-04-27 01:38:20 +01:00
|
|
|
}
|
|
|
|
}
|