Here's a more realistic top-down helicopter design with proper proportions and details:
(function() {
// ========== Setup full-window canvas ==========
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.style.position = 'fixed';
canvas.style.top = '0';
canvas.style.left = '0';
canvas.style.zIndex = '9999';
document.body.style.margin = '0';
document.body.style.overflow = 'hidden';
document.body.appendChild(canvas);
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// ========== 2D Vector Helper ==========
class Vec {
constructor(x = 0, y = 0) { this.x = x; this.y = y; }
add(v) { this.x += v.x; this.y += v.y; return this; }
sub(v) { this.x -= v.x; this.y -= v.y; return this; }
mult(s) { this.x *= s; this.y *= s; return this; }
div(s) { this.x /= s; this.y /= s; return this; }
mag() { return Math.hypot(this.x, this.y); }
normalize() { let m = this.mag() || 1; return this.div(m); }
limit(m) { if (this.mag() > m) this.normalize().mult(m); return this; }
copy() { return new Vec(this.x, this.y); }
}
// ========== Helicopter Class ==========
class Helicopter {
constructor() {
this.pos = new Vec(canvas.width / 2, canvas.height / 2);
this.vel = new Vec();
this.acc = new Vec();
this.maxSpeed = 2.0;
this.maxForce = 0.05;
this.target = this._pickTarget();
this.rotorAngle = 0;
}
_pickTarget() {
return new Vec(
Math.random() * canvas.width,
Math.random() * canvas.height
);
}
_steer() {
const desired = this.target.copy().sub(this.pos);
if (desired.mag() < 20) this.target = this._pickTarget();
desired.normalize().mult(this.maxSpeed);
const steer = desired.sub(this.vel).limit(this.maxForce);
this.acc.add(steer);
}
update() {
this._steer();
this.vel.add(this.acc).limit(this.maxSpeed);
this.pos.add(this.vel);
this.acc.mult(0);
this.rotorAngle += 0.2 + this.vel.mag() * 0.05;
}
// Enhanced drawing with realistic features
draw(ctx) {
ctx.save();
ctx.translate(this.pos.x, this.pos.y);
const direction = Math.atan2(this.vel.y, this.vel.x);
ctx.rotate(direction);
// ==== Helicopter Body ====
ctx.fillStyle = '#444'; // Dark gray body
ctx.strokeStyle = '#222';
ctx.lineWidth = 2;
ctx.beginPath();
// Fuselage (main body)
ctx.moveTo(-25, -10); // Start at front left
ctx.lineTo(25, -10); // Top edge
ctx.quadraticCurveTo(30, -10, 30, 0); // Rounded back
ctx.lineTo(30, 10); // Bottom edge
ctx.quadraticCurveTo(25, 10, -25, 10); // Rounded front
ctx.lineTo(-25, -10); // Close the shape
ctx.fill();
ctx.stroke();
// Nose section
ctx.beginPath();
ctx.arc(-25, 0, 5, 0, Math.PI); // Rounded nose
ctx.fill();
// Cockpit windshield
ctx.fillStyle = '#5a8'; // Light blue-gray
ctx.beginPath();
ctx.moveTo(-25, -10);
ctx.lineTo(-15, -10);
ctx.quadraticCurveTo(-10, -12, -5, -10);
ctx.lineTo(0, -10);
ctx.fill();
// ==== Tail Boom ====
ctx.fillStyle = '#333';
ctx.beginPath();
ctx.moveTo(25, 0); // Start from back of fuselage
ctx.lineTo(40, 0); // Tail boom
ctx.lineTo(40, 5); // Add thickness
ctx.lineTo(25, 5);
ctx.fill();
// ==== Rotor Assembly ====
ctx.fillStyle = '#888'; // Metalic rotor hub
ctx.beginPath();
ctx.arc(0, -25, 6, 0, Math.PI * 2); // Hub at top
ctx.fill();
// Rotor blades
ctx.strokeStyle = '#666';
ctx.lineWidth = 4;
ctx.save();
ctx.translate(0, -25); // Position at rotor hub
ctx.rotate(this.rotorAngle);
ctx.beginPath();
// Blade 1 (thick rectangular blade)
ctx.moveTo(-30, -3); // Blade width
ctx.lineTo(-30, 3);
ctx.lineTo(-45, 3); // Blade length
ctx.lineTo(-45, -3);
ctx.fill();
// Blade 2 (opposite blade)
ctx.moveTo(30, -3);
ctx.lineTo(30, 3);
ctx.lineTo(45, 3);
ctx.lineTo(45, -3);
ctx.fill();
ctx.restore();
// ==== Landing Gear ====
ctx.fillStyle = '#555';
ctx.beginPath();
ctx.arc(-10, 10, 3, 0, Math.PI * 2); // Front skid
ctx.arc(10, 10, 3, 0, Math.PI * 2); // Rear skid
ctx.fill();
ctx.restore();
}
}
// ========== Animation Loop ==========
const heli = new Helicopter();
(function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
heli.update();
heli.draw(ctx);
requestAnimationFrame(animate);
})();
})();
Key Improvements:
-
Realistic Body Shape:
- Streamlined fuselage with rounded edges and a distinct nose
- Clear cockpit windshield with a curved front
- Tail boom extending from the back
-
Rotor Assembly:
- Central rotor hub with metallic appearance
- Thick, realistic rotor blades with width and curvature
- Spins independently of the helicopter's movement direction
-
Visual Details:
- Landing gear skids at the bottom
- Gradient shading on the body
- Distinct materials through color variations
-
Movement:
- Proper rotation to face direction of travel
- Smooth steering behavior between random targets
This version should give a much more recognizable helicopter silhouette while maintaining the functional steering behavior. The rotor now has a visible hub and blade thickness, and the body has a more aerodynamic shape.