Download task_049/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 2.97 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_049/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_049/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_049/instruction.md
Build a deterministic Flappy Bird game
Create a single offline index.html in HTML/CSS/JavaScript. Draw a bird, scrolling pipe pairs with openings, and readable score and status. Use a canvas of at least 100×100 with data-testid="canvas", and mark the score, status, flap and new-game controls with corresponding data-testid values score, status, flap and new-game. Spacebar and the flap button perform the same action.
State and coordinates
Expose window.__game with init(config), getState(), flap() and step(dtMs). Initialization and stepping return the resulting state. Return an independent JSON snapshot from getState():
{bird:{y,vy}, pipes:[{x,gapY,gapH,passed}], score,status,width,height}
Coordinates start at the top left, with y increasing downward. Pipe x is the left edge, and the open interval from gapY to gapY + gapH is the gap. Document these conventions in the code. All init fields are optional:
seed(integer),gravity,flapImpulse,pipeSpeed,gapH,pipeInterval,widthandheight.birdXandbirdYlocate the bird's center.birdX,birdRandpipeWidthdefault to 60, 12 and 52 pixels. Use the radius for drawing and pipe collisions.birdYdefaults toheight/2andbirdVyto 0.- An explicit
pipesarray supplies the initial layout unchanged.autoPipesdefaults to false whenpipesis supplied and true otherwise. Default initialization shows at least one upcoming pipe. status: 'playing'starts in play immediately; otherwise initialize'ready'. After collision use'over'. Put the current state value as text in the status element, with any explanatory label outside it.
Acceptance Checklist
- Flap starts play from ready and sets vertical velocity to
-flapImpulse. Gravity pulls the bird down at fixed horizontal position; pipes move left. For eachstep(dtMs)in play, updatevy += gravity * dtMs / 16, theny += vy * dtMs / 16, and subtractpipeSpeed * dtMs / 16from each pipe's x. - A safe crossing of a pipe's right edge scores exactly one and sets its
passedflag. A collision in the crossing step does not score. Passing through an opening is safe, and hitting a solid pipe ends play. With no pipe collision, play continues while the bird's center is inside0 < y < height, including when the rendered bird overlaps the ground or ceiling. End play aty <= 0ory >= height. After game over, flap and step are no-ops. - The same seed and actions give identical pipe sequences and trajectories; different seeds influence the sequence. Changing a returned snapshot cannot change the game.
- Display actual injected geometry and state in the canvas, using distinct colors. Real inputs update the same simulation and display. A normal page load advances play through animation frames calling
step(16). In a manually initialized scenario, elapsed wall time does not advance state; advance it only through explicit steps.