{
"id": "259",
"prompt": "A vertical rocket hop with real flight readouts: holding the pointer burns fuel (240 units, minus one per thrust frame) for upward acceleration 9 against gravity 4, all in 1/8-px fixed point in state slots. Track altitude and velocity; once the ship has climbed past 80px it is committed - returning to the ground faster than 5px/frame is a CRASH, slower is a clean LANDED, each ending on its own message screen that a fresh tap resets. HUD shows a fuel bar, altitude, and speed with an up or down arrow drawn via draw_char (avoid printing negative numbers).",
"solution_rl": "fn iabs(v: i32) -> i32 {\n if v < 0 { -v } else { v }\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, 0);\n host::display::state_set(2, 0);\n host::display::state_set(3, 240);\n host::display::state_set(4, 0);\n host::display::state_set(6, 0);\n }\n let down: i32 = host::display::pointer_down();\n let prev: i32 = host::display::state_get(5);\n host::display::state_set(5, down);\n let mut alt: i32 = host::display::state_get(1);\n let mut v: i32 = host::display::state_get(2);\n let mut fuel: i32 = host::display::state_get(3);\n let phase: i32 = host::display::state_get(4);\n let mut flew: i32 = host::display::state_get(6);\n let thrusting: bool = phase == 0 && down == 1 && fuel > 0;\n if phase == 0 {\n if thrusting {\n v = v + 9;\n fuel = fuel - 1;\n }\n v = v - 4;\n alt = alt + v;\n if alt > 640 { flew = 1; }\n if alt <= 0 {\n alt = 0;\n if flew == 1 {\n if v < -40 {\n host::display::state_set(4, 1);\n } else {\n host::display::state_set(4, 2);\n }\n }\n v = 0;\n }\n host::display::state_set(1, alt);\n host::display::state_set(2, v);\n host::display::state_set(3, fuel);\n host::display::state_set(6, flew);\n } else {\n if down == 1 && prev == 0 {\n host::display::state_set(0, 0);\n }\n }\n host::display::clear(0x080810);\n host::display::fill_rect(0, h - 24, w, 24, 0x303428);\n host::display::fill_rect(w / 2 - 30, h - 30, 60, 6, 0x505050);\n let mut ry: i32 = h - 30 - 36 - alt / 8;\n if ry < 40 { ry = 40; }\n host::display::fill_rect(w / 2 - 8, ry, 16, 36, 0xd0d0d8);\n host::display::fill_rect(w / 2 - 8, ry - 10, 16, 10, 0xa04040);\n if thrusting {\n host::display::fill_rect(w / 2 - 5, ry + 36, 10, 14, 0xffa020);\n }\n host::display::draw_string(8, 8, \"FUEL\", 0x808080, 1);\n host::display::fill_rect(50, 8, fuel, 8, 0x40a0ff);\n host::display::draw_string(8, 24, \"ALT\", 0x808080, 1);\n host::display::draw_number(50, 24, alt / 8, 0xffffff, 1);\n host::display::draw_string(8, 40, \"SPD\", 0x808080, 1);\n host::display::draw_number(50, 40, iabs(v) / 8, 0xffffff, 1);\n if v > 0 { host::display::draw_char(90, 40, 94, 0x40ff60, 1); }\n if v < 0 { host::display::draw_char(90, 40, 118, 0xff5050, 1); }\n if phase == 1 {\n host::display::draw_string(w / 2 - 60, 80, \"CRASHED\", 0xff4030, 3);\n host::display::draw_string(w / 2 - 70, 120, \"TAP TO RETRY\", 0x808080, 1);\n }\n if phase == 2 {\n host::display::draw_string(w / 2 - 55, 80, \"LANDED\", 0x40ff60, 3);\n host::display::draw_string(w / 2 - 70, 120, \"TAP TO RETRY\", 0x808080, 1);\n }\n if phase == 0 {\n host::display::draw_string(8, h - 44, \"HOLD = THRUST\", 0x606060, 1);\n }\n host::display::present();\n}\n",
"tags": [
"simulation",
"physics",
"state",
"game-over"
]
}