captainliivo
prompt
MIT
This is a prompt to create the asteroid arcade game Captain Liivo.
Clone repository
https://liivo-liivogit.go-gitea-gitea.auto.prod.osaas.io/oscadmin/skills-captainliivo.git
Prompt
Captain Liivo Build Prompt
Use this prompt when asking another coding agent or developer to build a game in the same shape and spirit as Captain Liivo.
Build a small browser arcade game called "Captain Liivo".
The game should be a polished, playable, single-page web game where the player pilots a rocket shuttle and defends a ringed planet from incoming asteroids while dodging laser fire from a UFO.
Core experience:
- Make the game run immediately in the browser with no backend dependency.
- Use a vertical portrait playfield around 390x720 logical pixels, scaled responsively to desktop and mobile screens.
- Render the action on an HTML canvas.
- Include a HUD with score, planet integrity, player hull, and current terrain/state.
- Start on an overlay with the title "Captain Liivo", a short mission description, and a Launch button.
- Support keyboard controls, pointer/touch movement, and on-screen mobile controls.
Theme and art direction:
- The player is a bright rocket shuttle near the lower half of the screen.
- A ringed planet sits in the upper-right quadrant and must be protected.
- A UFO patrols near the upper-left and fires red lasers downward.
- Asteroids drift toward the planet from the top and later from the right side.
- Include starfield motion, impact sparks, screen shake, glow, and brief damage flashes.
- Use a dark space palette with cyan, gold, white, and red accents.
- Keep the UI compact and arcade-like, not a marketing page.
Gameplay rules:
- The player can move left, right, up, and down, but should stay in the lower/playable portion of the field.
- The player fires upward lasers or bullets.
- Bullets destroy asteroids. Normal asteroids take one hit; larger "Liivo" asteroids take multiple hits.
- Asteroids damage the planet if they reach it.
- Asteroids and UFO lasers damage the player's hull if they collide with the player.
- The planet slowly regenerates a small amount over time, but can still be overwhelmed.
- Hitting the UFO temporarily disables it, awards points, and drops a powerup.
- Powerups should also appear occasionally on a timer and can drop from larger asteroids.
- Powerups fall downward, grant a temporary speed/fire boost, restore a little hull, and award points.
- Reward clean asteroid clears with combo scoring, and reset the combo when the player takes hull damage.
- Add shifting terrain or hazard bands in the lower/middle playfield. They should change pattern every few seconds and damage the player on contact.
- Increase pressure over time or as score rises by spawning asteroids faster and raising speeds.
- Win when the score reaches about 2500 while the planet is still alive.
- Lose when the planet integrity or player hull reaches 0.
- Allow pause/resume with the P key and restart with Enter or the overlay button.
Implementation guidance:
- Keep the project simple: plain HTML, CSS, and modern JavaScript modules are enough.
- Prefer deterministic, testable helper functions for clamping, circular collision, rectangular point collision, initial state creation, and terrain layout generation.
- Keep game state in one clear object with mode, score, hull, planet integrity, level, timers, combo, player, UFO, bullets, lasers, asteroids, powerups, sparks, and stars.
- Use requestAnimationFrame for the game loop and cap delta time to avoid physics jumps after tab switches.
- Use circle collision for moving entities and point/rectangle checks for terrain hazards.
- Draw simple but expressive canvas shapes instead of relying on image assets.
- Make the canvas crisp on high-DPI displays by scaling the canvas backing size to devicePixelRatio.
- Keep touch controls accessible with aria labels and stable button sizes.
Liivo/OSC deployment requirements:
- Structure the project as one deployable app per repository, with `package.json` at the repository root.
- The root `package.json` must include `npm run build` and `npm start`.
- `npm run build` should be enough for Liivo to validate the app from the repository root.
- `npm start` should start the production/static server from the repository root.
- The server must listen on `process.env.PORT` when it is provided by Liivo/OSC.
- When `process.env.PORT` is set, bind the server to `0.0.0.0`; for local development, `127.0.0.1` is fine.
- Do not require external services, databases, secrets, or environment variables beyond Liivo/OSC's injected `PORT`.
- Avoid monorepo-only assumptions unless the Liivo deployment explicitly uses a `subPath`.
One possible file structure:
- index.html: page shell, HUD, canvas, overlay, and touch controls.
- styles.css: responsive layout, HUD styling, overlay, and touch controls.
- src/game.js: game constants, helpers, state, update loop, collision rules, drawing, input, and boot logic.
- src/game.test.mjs: unit tests for helper functions and initial state.
- server.mjs: tiny static file server for local play.
- package.json: scripts for start, test, and build.
Acceptance criteria:
- `npm start` serves the game locally.
- `npm run build` syntax-checks the app and runs tests.
- The same root scripts are suitable for a Liivo/OSC Node.js My App deployment.
- The server respects Liivo/OSC's injected `PORT` and binds publicly inside the container.
- The game is playable with keyboard, mouse/pointer, and touch controls.
- The HUD updates correctly during play.
- The player can shoot asteroids, collect powerups, take damage, pause, win, lose, and restart.
- The planet visibly reacts to damage.
- The UFO patrols, fires lasers, can be disabled by player shots, and resumes afterward.
- The terrain/hazard pattern changes during play.
- The layout works on narrow mobile screens and desktop without text overlap.
Notes For Rebuilders
This prompt describes the behavior and feel rather than requiring the exact same source code. A successful rebuild can use different internal names, tuning values, rendering details, or project scaffolding as long as the resulting game has the same core loop: pilot the rocket, defend the planet, survive the UFO and terrain hazards, collect boosts, and reach the score goal before hull or planet integrity runs out.