{
"id": "130",
"prompt": "Tap-battle tug of war: every tap of mine yanks the rope knot 14px toward my side while the CPU drags it left every frame, with hash-driven surge seconds where it pulls double. Pull the knot into the green zone to win the round, get dragged into the red to lose; keep a running wins/losses score on the field, announce the result, and a tap starts the next round.",
"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 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, w / 2);\n host::display::state_set(2, 0);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(5) == 0;\n host::display::state_set(5, down);\n let phase: i32 = host::display::state_get(2);\n if phase != 0 {\n if phase == 1 {\n host::display::clear(0x041804);\n host::display::draw_string(120, 190, \"YOU HAULED IT IN\", 0x00ff88, 3);\n } else {\n host::display::clear(0x180404);\n host::display::draw_string(110, 190, \"DRAGGED THROUGH\", 0xff4040, 3);\n }\n host::display::draw_number(190, 250, host::display::state_get(3), 0x00ff88, 4);\n host::display::draw_number(290, 250, host::display::state_get(4), 0xff4040, 4);\n host::display::draw_string(130, 330, \"TAP FOR ROUND\", 0x808080, 2);\n host::display::draw_number(400, 330, host::display::state_get(6) + 2, 0x808080, 2);\n if tap {\n host::display::state_set(6, host::display::state_get(6) + 1);\n host::display::state_set(1, w / 2);\n host::display::state_set(2, 0);\n }\n } else {\n let mut x: i32 = host::display::state_get(1);\n let round: i32 = host::display::state_get(6);\n if tap { x = x + 14; }\n x = x - 1;\n if hash(t / 60 + round * 99) % 3 == 0 { x = x - 1; }\n if x <= 60 {\n host::display::state_set(2, 2);\n host::display::state_set(4, host::display::state_get(4) + 1);\n }\n if x >= w - 60 {\n host::display::state_set(2, 1);\n host::display::state_set(3, host::display::state_get(3) + 1);\n }\n host::display::state_set(1, x);\n host::display::clear(0x101418);\n host::display::fill_rect(0, 0, 60, h, 0x301010);\n host::display::fill_rect(w - 60, 0, 60, h, 0x103014);\n host::display::fill_rect(60, h / 2 - 3, w - 120, 6, 0x6a5030);\n host::display::fill_rect(w / 2 - 1, h / 2 - 30, 2, 60, 0x404040);\n host::display::fill_rect(x - 8, h / 2 - 16, 16, 32, 0xffcc44);\n host::display::draw_string(110, 80, \"TAP FAST TO PULL RIGHT\", 0xffffff, 2);\n host::display::draw_string(70, h - 90, \"CPU\", 0xff4040, 2);\n host::display::draw_string(w - 130, h - 90, \"YOU\", 0x00ff88, 2);\n host::display::draw_number(120, 120, host::display::state_get(4), 0xff4040, 2);\n host::display::draw_number(w - 140, 120, host::display::state_get(3), 0x00ff88, 2);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"prng",
"pointer"
]
}