{
"id": "135",
"prompt": "Cave flyer: hold the pointer to climb, release to sink (velocity clamped), while a tunnel of rock strips scrolls past - the gap centerline interpolates LCG hashes of 128px segments, so the cave is fully deterministic with zero stored terrain. Clipping the rock ends the run; show seconds flown and the best, tap to fly again.",
"solution_rl": "fn hash(seed: i32) -> i32 {\n let mut h: i32 = seed * 747796405 + 2891336453;\n h = (h >> 16) ^ h;\n if h < 0 { h = 0 - h; }\n h\n}\n\nfn gap_at(worldx: i32, h: i32) -> i32 {\n let seg: i32 = worldx / 128;\n let a: i32 = 100 + hash(seg * 13) % (h - 200);\n let b: i32 = 100 + hash((seg + 1) * 13) % (h - 200);\n a + (b - a) * (worldx % 128) / 128\n}\n\nfn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n if host::display::state_get(0) == 0 {\n host::display::state_set(0, 1);\n host::display::state_set(1, (h / 2) * 8);\n host::display::state_set(2, 0);\n host::display::state_set(3, t);\n host::display::state_set(5, 0);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(6) == 0;\n host::display::state_set(6, down);\n let sec: i32 = (t - host::display::state_get(3)) / 60;\n if host::display::state_get(5) == 1 {\n host::display::clear(0x140a06);\n host::display::draw_string(120, 180, \"HIT THE ROCK\", 0xff6633, 4);\n host::display::draw_string(120, 250, \"FLEW FOR\", 0x808080, 2);\n host::display::draw_number(290, 244, host::display::state_get(7), 0xffffff, 3);\n host::display::draw_string(120, 284, \"BEST\", 0x808080, 2);\n host::display::draw_number(290, 278, host::display::state_get(4), 0x00ff88, 3);\n host::display::draw_string(110, 350, \"TAP TO FLY AGAIN\", 0x808080, 2);\n if tap { host::display::state_set(0, 0); }\n } else {\n let mut yf: i32 = host::display::state_get(1);\n let mut vy: i32 = host::display::state_get(2);\n if down == 1 { vy = vy - 1; } else { vy = vy + 1; }\n if vy > 6 { vy = 6; }\n if vy < -6 { vy = -6; }\n yf = yf + vy;\n host::display::state_set(1, yf);\n host::display::state_set(2, vy);\n let py: i32 = yf / 8;\n host::display::clear(0x0a0e14);\n let mut sx: i32 = 0;\n while sx < w / 16 {\n let c: i32 = gap_at(t * 4 + sx * 16, h);\n host::display::fill_rect(sx * 16, 0, 16, c - 64, 0x5a3a22);\n host::display::fill_rect(sx * 16, c + 64, 16, h - c - 64, 0x5a3a22);\n sx = sx + 1;\n }\n let c5: i32 = gap_at(t * 4 + 80, h);\n if py < c5 - 56 || py + 16 > c5 + 56 {\n host::display::state_set(5, 1);\n host::display::state_set(7, sec);\n if sec > host::display::state_get(4) {\n host::display::state_set(4, sec);\n }\n }\n host::display::fill_triangle(80, py, 80, py + 16, 100, py + 8, 0x00ddff);\n host::display::fill_rect(74, py + 4, 8, 8, 0x0088aa);\n host::display::draw_number(w - 80, 12, sec, 0xffffff, 3);\n host::display::draw_string(8, 12, \"HOLD TO CLIMB\", 0x806040, 1);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"prng",
"animation"
]
}