<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"> <title>High-Fidelity…
- User
IDLEWALKATTACK<script> const canvas = document.getElementById('gameCanvas'); const ctx = canvas.getContext('2d'); // --- THE ENGINE BLUEPRINT (Target Keyframe Multi-Joint Constraints) --- const ANIMATION_KEYS = { idle: { torso: { x: 128, y: 130, scaleY: 1.0 }, head: { x: 128, y: 100, rot: 0 }, lArm: { rot: 0.2, length: 30 }, rArm: { rot: -0.2, length: 30 }, lLeg: { rot: 0.1, length: 35 }, rLeg: { rot: -0.1, length: 35 }, capeSwing: 0, swordSwing: 0 }, walk: { // Populated dynamically in the loop via Math.sin for fluid cycles cycleSpeed: 0.006 }, attack: { cycleSpeed: 0.01 } }; // Current runtime state of the skeleton let currentSkeleton = { torso: { x: 128, y: 130, scaleY: 1.0 }, head: { x: 128, y: 100, rot: 0 }, lArm: { rot: 0, length: 30 }, rArm: { rot: 0, length: 30 }, lLeg: { rot: 0, length: 35 }, rLeg: { rot: 0, length: 35 }, capeSwing: 0, swordAngle: 0 }; let activeState = 'idle'; let lastTime = 0; function setAnimation(state) { activeState = state; document.querySelectorAll('button').forEach(b => b.classList.remove('active')); document.getElementByIdbtn-${state}`).classList.add('active'); } // Linear Interpolation helper for sub-pixel smoothing function lerp(start, end, amt) { return (1 - amt) start + amt end; } // --- RENDERING LAYER PIPELINE (Vectors & Gradients replace raw text) --- function drawLimb(ctx, startX, startY, angle, length, thickness, color, armorColor) { ctx.save(); ctx.translate(startX, startY); ctx.rotate(angle); // Draw base shadow/limb structure ctx.strokeStyle = color; ctx.lineWidth = thickness; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo(0, 0); ctx.lineTo(0, length); ctx.stroke(); // Overlay high-fidelity plate armor visuals ctx.strokeStyle = armorColor; ctx.lineWidth = thickness - 4; ctx.beginPath(); ctx.moveTo(0, 2); ctx.lineTo(0, length - 4); ctx.stroke(); ctx.restore(); } function drawCape(ctx, tx, ty, swing) { ctx.fillStyle = '#a61c26'; // Deep Crimson ctx.beginPath(); ctx.moveTo(tx - 10, ty + 5); // Dynamic physics calculation using quadratic curves for fabric sway ctx.quadraticCurveTo(tx - 35 + swing, ty + 30, tx - 25 + swing, ty + 70); ctx.lineTo(tx + 5, ty + 65); ctx.quadraticCurveTo(tx - 5, ty + 30, tx + 10, ty + 5); ctx.fill(); } function drawSword(ctx, handX, handY, angle) { ctx.save(); ctx.translate(handX, handY); ctx.rotate(angle); // Guard ctx.fillStyle = '#d4af37'; // Gold trim ctx.fillRect(-12, 0, 24, 6); // Blade let bladeGrad = ctx.createLinearGradient(0, -50, 0, 0); bladeGrad.addColorStop(0, '#ffffff'); // Shiny highlight sheen bladeGrad.addColorStop(1, '#7a889e'); // Base steel ctx.fillStyle = bladeGrad; ctx.fillRect(-4, -55, 8, 55); ctx.restore(); } function drawHeadAndTorso(ctx, skel) { // Torso armor plate construction let bodyGrad = ctx.createLinearGradient(skel.torso.x - 20, 0, skel.torso.x + 20, 0); bodyGrad.addColorStop(0, '#3a415a'); bodyGrad.addColorStop(0.5, '#626e94'); // Light highlight point bodyGrad.addColorStop(1, '#202433'); ctx.fillStyle = bodyGrad; ctx.beginPath(); ctx.ellipse(skel.torso.x, skel.torso.y + 15, 20, 25 2); ctx.fill(); // Gold filigree breastplate trim ctx.strokeStyle = '#d4af37'; ctx.lineWidth = 3; ctx.beginPath(); ctx.arc(skel.torso.x, skel.torso.y + 10, 12, 0, Math.PI, false); ctx.stroke(); // Helmet setup (); ctx.translate(skel.head.x, skel.head.y); ctx.rotate(skel.head.rot); // Crest plume ctx.fillStyle = '#de2735'; ctx.beginPath(); ctx.arc(-5, -15, 12, 0, Math.PI 2); ctx.fill(); // Steel dome ctx.fillStyle = '#4e5775'; ctx.beginPath(); ctx.arc(0, 0, 16, 0, Math.PI 0.003); target = { ...ANIMATION_KEYS.idle }; target.torso.y += pulse 0.02); target.head.y += pulse 4; target.swordAngle = -Math.PI / 4 + (pulse ANIMATION_KEYS.walk.cycleSpeed; const walkCycle = Math.sin(timeFactor); const bob = Math.abs(Math.cos(timeFactor)); target = { torso: { x: 128, y: 130 + (bob 2.5), rot: walkCycle 0.6) + 0.2, length: 30 }, rArm: { rot: (-walkCycle 0.7, length: 35 }, rLeg: { rot: walkCycle 8, swordAngle: (-Math.PI / 6) + (walkCycle ANIMATION_KEYS.attack.cycleSpeed; const lunge = Math.sin(timeFactor); target = { torso: { x: 128 + (lunge 15), y: 104, rot: 0.2 }, lArm: { rot: -0.8 + (lunge 0.3), length: 35 }, rLeg: { rot: -0.6 + (lunge 20, swordAngle: (-Math.PI / 2) + (lunge lunge, 0, Math.PI*2); ctx.fill(); } } // 3. FRAME INTERPOLATION SMOOTHING (Removes robotic stepping mechanics) const blendRate = 0.15; // Smooth convergence factor currentSkeleton.torso.x = lerp(currentSkeleton.torso.x, target.torso.x, blendRate); currentSkeleton.torso.y = lerp(currentSkeleton.torso.y, target.torso.y, blendRate); currentSkeleton.torso.scaleY = lerp(currentSkeleton.torso.scaleY, target.torso.scaleY, blendRate); currentSkeleton.head.x = lerp(currentSkeleton.head.x, target.head.x, blendRate); currentSkeleton.head.y = lerp(currentSkeleton.head.y, target.head.y, blendRate); currentSkeleton.head.rot = lerp(currentSkeleton.head.rot, target.head.rot, blendRate); currentSkeleton.lArm.rot = lerp(currentSkeleton.lArm.rot, target.lArm.rot, blendRate); currentSkeleton.rArm.rot = lerp(currentSkeleton.rArm.rot, target.rArm.rot, blendRate); currentSkeleton.lLeg.rot = lerp(currentSkeleton.lLeg.rot, target.lLeg.rot, blendRate); currentSkeleton.rLeg.rot = lerp(currentSkeleton.rLeg.rot, target.rLeg.rot, blendRate); currentSkeleton.capeSwing = lerp(currentSkeleton.capeSwing, target.capeSwing, blendRate); currentSkeleton.swordAngle = lerp(currentSkeleton.swordAngle, target.swordAngle, blendRate); // 4. COMPOSITED LAYER DRAW ORDER RENDERING // Layer 1: Cape (Behind) drawCape(ctx, currentSkeleton.torso.x, currentSkeleton.torso.y, currentSkeleton.capeSwing); // Layer 2: Back limbs drawLimb(ctx, currentSkeleton.torso.x - 10, currentSkeleton.torso.y + 25, currentSkeleton.rLeg.rot, currentSkeleton.rLeg.length, 12, '#1a1d24', '#343b4d'); drawLimb(ctx, currentSkeleton.torso.x - 12, currentSkeleton.torso.y + 5, currentSkeleton.rArm.rot, currentSkeleton.rArm.length, 10, '#1a1d24', '#343b4d'); // Layer 3: Center Core (Torso & Head Assembly) drawHeadAndTorso(ctx, currentSkeleton); // Layer 4: Front Limbs & Equipment Interfacing drawLimb(ctx, currentSkeleton.torso.x + 10, currentSkeleton.torso.y + 25, currentSkeleton.lLeg.rot, currentSkeleton.lLeg.length, 13, '#202433', '#4e5775'); // Calculate exact left hand position coordinates dynamically to anchor the sword hilt to the arm bone terminal point const handX = currentSkeleton.torso.x + 12 + Math.sin(-currentSkeleton.lArm.rot) currentSkeleton.lArm.length; drawLimb(ctx, currentSkeleton.torso.x + 12, currentSkeleton.torso.y + 5, currentSkeleton.lArm.rot, currentSkeleton.lArm.length, 11, '#202433', '#4e5775'); drawSword(ctx, handX, handY, currentSkeleton.swordAngle); requestAnimationFrame(updateAndRender); } // Initialize Loop requestAnimationFrame(updateAndRender); please improve my ASCII - Procedural Sprite Generation (or Procedural Asset Generation). I want to have a better code for creating such character with animations. Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.