-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathskipahead.cwa
70 lines (56 loc) · 1.75 KB
/
skipahead.cwa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Sizecoded port of my TIC-80 game "skip ahead"
// 512 bytes of uncompressed wasm
import "env.memory" memory(1);
import "env.rect" fn rect(i32, i32, i32, i32);
import "env.oval" fn oval(i32, i32, i32, i32);
import "env.text" fn text(i32, i32, i32);
global mut pz: i32 = 30;
global mut px: f32 = 0.0;
global mut py: f32 = 0.0;
global mut s: f32 = 0.0;
global mut f: f32 = 0.0;
fn rng(state: i32) -> i32 {
94614859 * (state ^ (state #>> 17))
}
fn set_color(color: i32) -> i32 {
0?20 = color;
6
}
export fn update() {
let y: i32;
let score = pz;
let lazy pad = 0?22;
let lazy zero = 0.0;
let lazy control_speed = 0.03;
s = s + 0.1 - (f + control_speed) * (pad & 1) as f32;
f = f * 0.7;
loop lines {
(8003-y)?0 = (score := score / 10) % 10 + 48;
let lazy z = (4000 / (y := y + 1) + pz) / 20;
let lazy x = (rng(rng(rng(rng(z)))) >> 30) as f32 - px;
let lazy w = 9 as f32 / sqrt(z as f32);
let lazy rx = 80 + (y as f32 * x) as i32;
let lazy rw = (y as f32 * w) as i32;
let lazy c = ((z & 1) + 2) * 17;
rect(rx, y, rw, y / set_color(c + 17));
text(8000, set_color(c) <| rect(rx, y, rw, 1), set_color(4));
if y == 120 & py > zero {
if x < -w | x > zero {
if pad & 2 {
pz = 30;
px = zero;
}
return;
}
py = zero;
s = zero;
f = 0.8;
}
branch_if y < 160: lines;
}
let lazy sy = 114 - 11 + py as i32;
oval(80 - 6, sy + 5, (set_color(50) <| oval(80 - 11, sy, 22, 22)), set_color(17));
px = px + (!(pad & 16) - !(pad & 32)) as f32 * control_speed;
py = py + s;
pz = pz + 1;
}