{
"id": "123",
"prompt": "An endless runner like the Chrome dino in a 480x270 landscape cartridge (dims() packs (480 << 16) | 270). Tap to jump with fixed-point gravity, one cactus scrolls in from the right faster as the score grows, each cleared cactus scores, and a collision shows CLEARED plus BEST with a tap to run again. Keep jump state, obstacle x and best in state slots - locals do not survive the frame.",
"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 { (480 << 16) | 270 }\n\nfn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let gy: i32 = h - 40;\n if host::display::state_get(0) == 0 {\n host::display::state_set(0, 1);\n host::display::state_set(1, 0);\n host::display::state_set(2, 0);\n host::display::state_set(3, w);\n host::display::state_set(4, 1);\n host::display::state_set(5, 0);\n host::display::state_set(6, 0);\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 let score: i32 = host::display::state_get(5);\n if host::display::state_get(6) == 1 {\n host::display::clear(0x101010);\n host::display::draw_string(150, 80, \"TRIPPED\", 0xff4040, 4);\n host::display::draw_string(120, 140, \"CLEARED\", 0x808080, 2);\n host::display::draw_number(260, 134, score, 0xffffff, 3);\n host::display::draw_string(120, 174, \"BEST\", 0x808080, 2);\n host::display::draw_number(260, 168, host::display::state_get(8), 0x00ff88, 3);\n host::display::draw_string(140, 220, \"TAP TO RUN\", 0x808080, 2);\n if tap { host::display::state_set(0, 0); }\n } else {\n let mut dy: i32 = host::display::state_get(1);\n let mut vy: i32 = host::display::state_get(2);\n if tap && dy == 0 { vy = 44; }\n dy = dy + vy;\n vy = vy - 4;\n if dy <= 0 { dy = 0; vy = 0; }\n host::display::state_set(1, dy);\n host::display::state_set(2, vy);\n let mut ox: i32 = host::display::state_get(3);\n let mut spd: i32 = 5 + score / 5;\n if spd > 9 { spd = 9; }\n ox = ox - spd;\n if ox < -24 {\n let rnd: i32 = host::display::state_get(4) + 1;\n host::display::state_set(4, rnd);\n ox = w + hash(rnd) % 140;\n host::display::state_set(5, score + 1);\n }\n host::display::state_set(3, ox);\n let dtop: i32 = gy - 30 - dy / 8;\n if 50 + 26 > ox && 50 < ox + 20 && dtop + 30 > gy - 24 {\n host::display::state_set(6, 1);\n if score > host::display::state_get(8) {\n host::display::state_set(8, score);\n }\n }\n host::display::clear(0xf0f0e8);\n host::display::fill_rect(0, gy, w, 2, 0x202020);\n let mut mx: i32 = 0 - (t * 2) % 60;\n while mx < w {\n host::display::fill_rect(mx, gy + 10, 20, 2, 0xb0b0a8);\n mx = mx + 60;\n }\n host::display::fill_rect(50, dtop, 26, 30, 0x303030);\n host::display::fill_rect(68, dtop + 4, 6, 6, 0xf0f0e8);\n host::display::fill_rect(ox, gy - 24, 20, 24, 0x117733);\n host::display::fill_rect(ox - 6, gy - 16, 6, 10, 0x117733);\n host::display::fill_rect(ox + 20, gy - 18, 6, 10, 0x117733);\n host::display::draw_number(w - 90, 10, score, 0x202020, 3);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"dims",
"prng"
]
}