gpt-4.1-mini-2025-04-14· OpenAI
LMArena Human Preference 140K
Generate a html/js game that recrates touhou 6
- User
Generate a html/js game that recrates touhou 6
- Assistant
Creating a full remake of Touhou 6: The Embodiment of Scarlet Devil is a massive project, as it's a complex bullet-hell shooter with many levels, enemies, bosses, and intricate bullet patterns. However, I can help you get started with a very basic HTML/JS framework that mimics the core gameplay elements:
- Player movement
- Shooting bullets
- Simple enemy spawning
- Basic collision detection
- A simple boss with a bullet pattern
This will be a minimal prototype to build upon.
Basic Touhou 6-like Shooter Prototype
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Touhou 6 Mini Prototype</title> <style> body { margin: 0; background: #000; overflow: hidden; } canvas { display: block; margin: 0 auto; background: #111; } </style> </head> <body> <canvas id="game" width="480" height="640"></canvas> <script> (() => { const canvas = document.getElementById('game'); const ctx = canvas.getContext('2d'); const WIDTH = canvas.width; const HEIGHT = canvas.height; // Player object const player = { x: WIDTH / 2, y: HEIGHT - 60, width: 20, height: 20, speed: 5, bullets: [], cooldown: 0, }; // Enemy object class Enemy { constructor(x, y, speed) { this.x = x; this.y = y; this.width = 20; this.height = 20; this.speed = speed; this.alive = true; } update() { this.y += this.speed; if (this.y > HEIGHT) this.alive = false; } draw() { ctx.fillStyle = 'red'; ctx.fillRect(this.x, this.y, this.width, this.height); } } // Bullet object class Bullet { constructor(x, y, speed, fromPlayer = true) { this.x = x; this.y = y; this.radius = 4; this.speed = speed; this.fromPlayer = fromPlayer; this.alive = true; } update() { this.y += this.speed; if (this.y < 0 || this.y > HEIGHT) this.alive = false; } draw() { ctx.fillStyle = this.fromPlayer ? 'cyan' : 'orange'; ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fill(); } } // Boss object with simple bullet pattern class Boss { constructor() { this.x = WIDTH / 2 - 40; this.y = 50; this.width = 80; this.height = 40; this.health = 100; this.bullets = []; this.shootCooldown = 0; this.moveDirection = 1; this.speed = 2; } update() { // Move left and right this.x += this.speed * this.moveDirection; if (this.x < 0 || this.x + this.width > WIDTH) { this.moveDirection *= -1; } // Shoot bullets in a simple spread pattern if (this.shootCooldown <= 0) { this.shootCooldown = 60; // frames cooldown for (let angle = -60; angle <= 60; angle += 30) { const rad = (angle * Math.PI) / 180; this.bullets.push(new BossBullet(this.x + this.width / 2, this.y + this.height, rad)); } } else { this.shootCooldown--; } // Update bullets this.bullets = this.bullets.filter(b => b.alive); this.bullets.forEach(b => b.update()); } draw() { ctx.fillStyle = 'purple'; ctx.fillRect(this.x, this.y, this.width, this.height); // Draw health bar ctx.fillStyle = 'red'; ctx.fillRect(this.x, this.y - 10, (this.health / 100) * this.width, 5); this.bullets.forEach(b => b.draw()); } } // Boss bullet with angle class BossBullet { constructor(x, y, angle) { this.x = x; this.y = y; this.radius = 6; this.speed = 3; this.angle = angle; this.alive = true; } update() { this.x += this.speed * Math.sin(this.angle); this.y += this.speed * Math.cos(this.angle); if (this.x < 0 || this.x > WIDTH || this.y > HEIGHT) this.alive = false; } draw() { ctx.fillStyle = 'orange'; ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fill(); } } // Input handling const keys = {}; window.addEventListener('keydown', e => { keys[e.key.toLowerCase()] = true; }); window.addEventListener('keyup', e => { keys[e.key.toLowerCase()] = false; }); // Collision detection function rectCircleColliding(circle, rect) { const distX = Math.abs(circle.x - rect.x - rect.width / 2); const distY = Math.abs(circle.y - rect.y - rect.height / 2); if (distX > (rect.width / 2 + circle.radius)) return false; if (distY > (rect.height / 2 + circle.radius)) return false; if (distX <= (rect.width / 2)) return true; if (distY <= (rect.height / 2)) return true; const dx = distX - rect.width / 2; const dy = distY - rect.height / 2; return (dx * dx + dy * dy <= (circle.radius * circle.radius)); } // Game state let enemies = []; let enemySpawnTimer = 0; const boss = new Boss(); let gameOver = false; function update() { if (gameOver) return; // Player movement if (keys['arrowleft'] || keys['a']) player.x -= player.speed; if (keys['arrowright'] || keys['d']) player.x += player.speed; if (keys['arrowup'] || keys['w']) player.y -= player.speed; if (keys['arrowdown'] || keys['s']) player.y += player.speed; // Keep player inside screen player.x = Math.max(0, Math.min(WIDTH - player.width, player.x)); player.y = Math.max(0, Math.min(HEIGHT - player.height, player.y)); // Player shooting if (keys[' ']) { if (player.cooldown <= 0) { player.bullets.push(new Bullet(player.x + player.width / 2, player.y, -7)); player.cooldown = 10; } } if (player.cooldown > 0) player.cooldown--; // Update player bullets player.bullets = player.bullets.filter(b => b.alive); player.bullets.forEach(b => b.update()); // Spawn enemies enemySpawnTimer--; if (enemySpawnTimer <= 0) { enemySpawnTimer = 90; enemies.push(new Enemy(Math.random() * (WIDTH - 20), -20, 2)); } // Update enemies enemies = enemies.filter(e => e.alive); enemies.forEach(e => e.update()); // Check collisions: player bullets vs enemies for (const bullet of player.bullets) { for (const enemy of enemies) { if ( bullet.alive && enemy.alive && bullet.x > enemy.x && bullet.x < enemy.x + enemy.width && bullet.y > enemy.y && bullet.y < enemy.y + enemy.height ) { bullet.alive = false; enemy.alive = false; } } } // Check collisions: player bullets vs boss for (const bullet of player.bullets) { if ( bullet.alive && bullet.x > boss.x && bullet.x < boss.x + boss.width && bullet.y > boss.y && bullet.y < boss.y + boss.height ) { bullet.alive = false; boss.health -= 1; if (boss.health <= 0) { alert('You defeated the boss! You win!'); gameOver = true; } } } // Update boss boss.update(); // Check collisions: boss bullets vs player for (const bBullet of boss.bullets) { if (rectCircleColliding(bBullet, player)) { alert('You got hit! Game Over.'); gameOver = true; } } // Check collisions: enemies vs player for (const enemy of enemies) { if ( enemy.alive && player.x < enemy.x + enemy.width && player.x + player.width > enemy.x && player.y < enemy.y + enemy.height && player.y + player.height > enemy.y ) { alert('You collided with an enemy! Game Over.'); gameOver = true; } } } function draw() { ctx.clearRect(0, 0, WIDTH, HEIGHT); // Draw player ctx.fillStyle = 'cyan'; ctx.fillRect(player.x, player.y, player.width, player.height); // Draw player bullets player.bullets.forEach(b => b.draw()); // Draw enemies enemies.forEach(e => e.draw()); // Draw boss boss.draw(); // Draw instructions ctx.fillStyle = 'white'; ctx.font = '14px Arial'; ctx.fillText('Move: Arrow Keys or WASD', 10, HEIGHT - 40); ctx.fillText('Shoot: Spacebar', 10, HEIGHT - 20); } function loop() { update(); draw(); if (!gameOver) requestAnimationFrame(loop); } loop(); })(); </script> </body> </html>
How to use this:
- Save the above code as
touhou6-prototype.html. - Open it in a modern browser.
- Use arrow keys or WASD to move.
- Press spacebar to shoot.
- Enemies spawn from the top and move down.
- A simple boss moves left and right near the top and shoots spread bullets.
- Colliding with enemies or boss bullets ends the game.
- Shooting the boss enough times wins the game.
What this prototype lacks compared to Touhou 6:
- Complex bullet patterns (danmaku)
- Multiple stages and bosses
- Player hitbox and grazing mechanics
- Scoring system
- Power-ups and bombs
- Sound and music
- Graphics and animations
If you want, I can help you expand this with more features, better bullet patterns, or polish! Just ask.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.