{
"id": "116",
"prompt": "Timing minigame: a white bar sweeps left-right across a center target zone, faster each round. I tap to stop it; closer to center scores more (max 100). After 5 rounds show the total and a rank chosen with a match over score ranges - 400..=500 sharpshooter, 250..400 solid, anything else practice more - plus tap to replay.",
"solution_rl": "fn 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, 0);\n host::display::state_set(2, 0);\n host::display::state_set(3, 0);\n host::display::state_set(5, 0);\n host::display::state_set(6, 1);\n host::display::state_set(7, 0);\n }\n let down: i32 = host::display::pointer_down();\n let tap: bool = down == 1 && host::display::state_get(4) == 0;\n host::display::state_set(4, down);\n let round: i32 = host::display::state_get(1);\n let total: i32 = host::display::state_get(2);\n if host::display::state_get(3) == 1 {\n host::display::clear(0x101018);\n host::display::draw_string(170, 150, \"FINAL SCORE\", 0x808080, 2);\n host::display::draw_number(210, 190, total, 0xffffff, 5);\n match total {\n 400..=500 => {\n host::display::draw_string(150, 280, \"SHARPSHOOTER\", 0x00ff88, 3);\n }\n 250..400 => {\n host::display::draw_string(200, 280, \"SOLID\", 0xffaa00, 3);\n }\n _ => {\n host::display::draw_string(130, 280, \"PRACTICE MORE\", 0xff4040, 3);\n }\n }\n host::display::draw_string(150, 350, \"TAP TO GO AGAIN\", 0x808080, 2);\n if tap { host::display::state_set(0, 0); }\n } else {\n let mut pos: i32 = host::display::state_get(5);\n let mut dir: i32 = host::display::state_get(6);\n let speed: i32 = 5 + round * 2;\n pos = pos + dir * speed;\n if pos < 0 { pos = 0; dir = 1; }\n if pos > w - 8 { pos = w - 8; dir = -1; }\n host::display::state_set(5, pos);\n host::display::state_set(6, dir);\n if tap {\n let mut dist: i32 = pos + 4 - w / 2;\n if dist < 0 { dist = -dist; }\n let mut pts: i32 = 50 - dist;\n if pts < 0 { pts = 0; }\n pts = pts * 2;\n host::display::state_set(2, total + pts);\n host::display::state_set(7, pts);\n host::display::state_set(1, round + 1);\n if round + 1 >= 5 { host::display::state_set(3, 1); }\n }\n host::display::clear(0x000000);\n host::display::draw_string(8, 10, \"ROUND\", 0x808080, 2);\n host::display::draw_number(110, 10, round + 1, 0xffffff, 2);\n host::display::draw_string(150, 10, \"OF 5\", 0x808080, 2);\n host::display::draw_string(8, 40, \"LAST\", 0x808080, 1);\n host::display::draw_number(50, 40, host::display::state_get(7), 0x00ff88, 1);\n host::display::draw_string(100, 40, \"TOTAL\", 0x808080, 1);\n host::display::draw_number(150, 40, total, 0xffffff, 1);\n host::display::fill_rect(w / 2 - 24, h / 2 - 30, 48, 60, 0x104020);\n host::display::fill_rect(w / 2 - 2, h / 2 - 30, 4, 60, 0x00ff88);\n host::display::fill_rect(0, h / 2 - 2, w, 4, 0x303030);\n host::display::fill_rect(pos, h / 2 - 24, 8, 48, 0xffffff);\n host::display::draw_string(120, h - 60, \"TAP TO STOP THE BAR\", 0x808080, 2);\n }\n host::display::present();\n}\n",
"tags": [
"game",
"state",
"match",
"ui"
]
}