Create a complete browser game using React (Vite) and HTML5 Canvas. Requirements: - This…
- User
Create a complete browser game using React (Vite) and HTML5 Canvas.
Requirements:
- This must be a REAL game with a proper game loop using requestAnimationFrame.
- The game updates and renders every frame (60 FPS target).
- No turn-based gameplay.
- No waiting for button presses between actions.
- Everything should continuously animate and simulate.
- Separate update() and render() functions.
- Delta time should be used so movement is frame-rate independent.
Game Idea: "Sky Salvager"
You control a small hover drone flying through the ruins of floating islands.
Gameplay:
- WASD or Arrow Keys to move.
- Mouse aims the drone.
- Left click shoots energy bolts.
- Enemies continuously spawn from screen edges and chase the player.
- Destroy enemies to collect glowing energy shards.
- Energy shards increase score.
- Every 20 seconds difficulty increases:
- Faster enemies
- More enemies
- New enemy types
- Player has health.
- Small health pickups occasionally spawn.
- Survive as long as possible.
Graphics:
- Clean minimalist 2D / 2.5D style.
- Layered parallax background.
- Floating islands.
- Animated clouds.
- Particles when shooting.
- Explosion particles.
- Camera shake when taking damage.
- Smooth easing animations.
- Screen flash on explosions.
Game Feel:
- Inertia when moving.
- Small recoil when shooting.
- Enemy knockback.
- Juice everywhere:
- particles
- hit flashes
- screen shake
- scaling effects
- smooth interpolation
Architecture:
- React is ONLY used for UI.
- Canvas handles all gameplay rendering.
- Use:
- Game.ts
- Player.ts
- Enemy.ts
- Projectile.ts
- Particle.ts
- Pickup.ts
- Input.ts
- Collision.ts
- Renderer.ts
- No giant single-file code.
UI:
- Health bar
- Score
- Timer
- Difficulty level
- FPS counter (optional)
- Pause menu
- Game Over screen
- Restart button
Collision:
- Circle collision detection.
- Spatial optimization if enemy count becomes high.
Performance:
- Object pooling for bullets and particles.
- Avoid unnecessary React rerenders.
- Game state lives outside React.
Audio:
- Procedural sound effects using Web Audio API.
- Background ambient music loop.
Extras:
- Dash ability with cooldown.
- Slow-motion effect for 0.2 seconds after taking heavy damage.
- Combo multiplier for consecutive kills.
- Floating damage numbers.
Code Quality:
- Modern TypeScript.
- Clean architecture.
- Easy to expand.
- Well-commented.
- No external game engine (no Phaser, Pixi, Three.js).
- Only React + Canvas + TypeScript.
The finished project should feel like a polished arcade survival game rather than a demo. The world should always be alive, with constant movement, animation, enemy AI, particle effects, and updates every frame.
- Assistant
Implemented Sky Salvager as a complete React + Vite + TypeScript browser game using HTML5 Canvas for all gameplay rendering.
Key files added:
src/game/Game.ts: requestAnimationFrame loop, update/render separation, delta-time simulation, spawning, difficulty, collisions, score, pause/restart/game-over statesrc/game/Player.ts: inertia movement, aiming, shooting recoil, dash, health, damage handlingsrc/game/Enemy.ts: enemy types, chase AI, scaling difficulty, knockback and hit flashessrc/game/Projectile.ts: pooled energy boltssrc/game/Particle.ts: pooled sparks, smoke, rings, damage numberssrc/game/Pickup.ts: energy shards and health pickupssrc/game/Input.ts: WASD/arrows, mouse aim, click fire, dash, pausesrc/game/Collision.ts: circle collision and spatial hash optimizationsrc/game/Renderer.ts: full Canvas renderer with parallax sky, floating islands, clouds, particles, flashes, shake, and entity renderingsrc/game/Audio.ts: procedural Web Audio effects and ambient loopsrc/App.tsx: React UI overlay only, including health, score, timer, difficulty, FPS, dash meter, pause menu, game-over screen, restart buttonsrc/index.css: app-wide fullscreen canvas styling
Verified with:
npm run build
The production build completed successfully.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.