Skip to content

Commit 2ff1bb7

Browse files
committed
Fix some diagnostic issues when skipping invalid statements, see AssemblyScript#80; Make game-of-life example somewhat interactive; Update dist files
1 parent fac0fc5 commit 2ff1bb7

File tree

17 files changed

+729
-1728
lines changed

17 files changed

+729
-1728
lines changed

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/game-of-life/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Conway's Game of Life
22
=====================
33

4-
An [AssemblyScript](http://assemblyscript.org) example. Continuously updates the cellular automaton and visualizes its state on a canvas. Compiles to ~750 bytes of optimized WASM.
4+
An [AssemblyScript](http://assemblyscript.org) example. Continuously updates the cellular automaton and visualizes its state on a canvas. Compiles to ~920 bytes of optimized WASM.
55

66
Instructions
77
------------

examples/game-of-life/assembly/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// see: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
22

3-
const RGB_ALIVE = 0xE692D3; // LSB must be set
4-
const RGB_DEAD = 0x851BA6; // LSB must not be set
5-
const BIT_ROT = 10; // It's everywhere
3+
// Configuration imported from JS.
4+
declare const RGB_ALIVE: u32;
5+
declare const RGB_DEAD: u32;
6+
declare const BIT_ROT: u32;
67

78
var w: i32, h: i32, s: i32;
89

@@ -76,3 +77,13 @@ export function step(): void {
7677
}
7778
}
7879
}
80+
81+
/** Fills the row and column indicated by `x` and `y` with random live cells. */
82+
export function fill(x: u32, y: u32, p: f64): void {
83+
for (let ix = 0; ix < w; ++ix) {
84+
if (Math.random() < p) set(ix, y, RGB_ALIVE | 0xff000000);
85+
}
86+
for (let iy = 0; iy < h; ++iy) {
87+
if (Math.random() < p) set(x, iy, RGB_ALIVE | 0xff000000);
88+
}
89+
}
189 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)