{
"id": "120",
"prompt": "Write a flappy-bird-style cartridge in portrait 320x480 - export dims() returning (w << 16) | h, each side 16..=1024. Tap to flap, gravity in fixed-point eighths, one pipe pair scrolling left whose LCG-picked gap respawns on the right and scores, and a collision or leaving the screen kills. Game over shows pipes cleared plus best, tap restarts.",
"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 dims() -> i32 { (320 << 16) | 480 }\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, w + 40);\n host::display::state_set(4, 90 + hash(1) % (h - 180));\n host::display::state_set(5, 0);\n host::display::state_set(6, 0);\n host::display::state_set(8, 1);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(7) == 0;\n host::display::state_set(7, down);\n if host::display::state_get(6) == 1 {\n host::display::clear(0x101018);\n host::display::draw_string(90, 160, \"SPLAT\", 0xff4040, 4);\n host::display::draw_string(60, 230, \"PIPES\", 0x808080, 2);\n host::display::draw_number(160, 224, host::display::state_get(5), 0xffffff, 3);\n host::display::draw_string(60, 264, \"BEST\", 0x808080, 2);\n host::display::draw_number(160, 258, host::display::state_get(9), 0x00ff88, 3);\n host::display::draw_string(70, 330, \"TAP TO FLAP\", 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 tap { vy = -38; }\n vy = vy + 3;\n if vy > 44 { vy = 44; }\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 let mut pxp: i32 = host::display::state_get(3) - 3;\n let mut gy: i32 = host::display::state_get(4);\n let mut score: i32 = host::display::state_get(5);\n if pxp < -48 {\n pxp = w;\n let rnd: i32 = host::display::state_get(8) + 1;\n host::display::state_set(8, rnd);\n gy = 90 + hash(rnd) % (h - 180);\n score = score + 1;\n host::display::state_set(5, score);\n }\n host::display::state_set(3, pxp);\n host::display::state_set(4, gy);\n let mut dead: i32 = 0;\n if py < 0 || py + 22 > h { dead = 1; }\n if 60 + 22 > pxp && 60 < pxp + 48 {\n if py < gy - 70 || py + 22 > gy + 70 { dead = 1; }\n }\n if dead == 1 {\n host::display::state_set(6, 1);\n if score > host::display::state_get(9) {\n host::display::state_set(9, score);\n }\n }\n host::display::clear(0x102030);\n host::display::fill_rect(pxp, 0, 48, gy - 70, 0x22aa44);\n host::display::fill_rect(pxp, gy + 70, 48, h - gy - 70, 0x22aa44);\n host::display::fill_rect(pxp - 4, gy - 86, 56, 16, 0x2fcc55);\n host::display::fill_rect(pxp - 4, gy + 70, 56, 16, 0x2fcc55);\n host::display::fill_rect(60, py, 22, 22, 0xffdd00);\n host::display::fill_rect(76, py + 6, 8, 6, 0xff8800);\n host::display::draw_number(w / 2 - 12, 16, score, 0xffffff, 4);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"dims",
"prng"
]
}