mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 06:51:34 +00:00
Fix some diagnostic issues when skipping invalid statements, see #80; Make game-of-life example somewhat interactive; Update dist files
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
// see: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
|
||||
|
||||
const RGB_ALIVE = 0xE692D3; // LSB must be set
|
||||
const RGB_DEAD = 0x851BA6; // LSB must not be set
|
||||
const BIT_ROT = 10; // It's everywhere
|
||||
// Configuration imported from JS.
|
||||
declare const RGB_ALIVE: u32;
|
||||
declare const RGB_DEAD: u32;
|
||||
declare const BIT_ROT: u32;
|
||||
|
||||
var w: i32, h: i32, s: i32;
|
||||
|
||||
@ -76,3 +77,13 @@ export function step(): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Fills the row and column indicated by `x` and `y` with random live cells. */
|
||||
export function fill(x: u32, y: u32, p: f64): void {
|
||||
for (let ix = 0; ix < w; ++ix) {
|
||||
if (Math.random() < p) set(ix, y, RGB_ALIVE | 0xff000000);
|
||||
}
|
||||
for (let iy = 0; iy < h; ++iy) {
|
||||
if (Math.random() < p) set(x, iy, RGB_ALIVE | 0xff000000);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user