Harika bir proje! İki çöp adamın (stickman) kıyasıya… · The Chat Archive
Explore Harika bir proje! İki çöp adamın (stickman) kıyasıya, sinematik ve tempolu dövüşünü… Save Share Download ▾ ReportHarika bir proje! İki çöp adamın (stickman) kıyasıya, sinematik ve tempolu dövüşünü oluşturacak bir web uygulaması tam bir Creative Coding ve Motion Design harikasıdır.
Sıradan bir statik render yerine, GSAP ile zamanlanan ve HTML5 Canvas üzerinde çalışan özel bir render motoru (kinematik pozlar, motion blur, particle efektleri, kamera sarsıntısı) inşa edeceğiz.
Teknik Plan ve Mimari
State Management (Zustand): Kullanıcı ayarlarını (isimler, renkler, kazanan, süre) ve oynatma durumunu (play, pause, loading) global olarak yöneteceğiz.
Animasyon Motoru (Canvas + GSAP):
Karakterleri tam matematiksel IK (Inverse Kinematics) yerine, yüksek performanslı "State-Based Pose Rendering" (Durum tabanlı poz çizimi) ile oluşturacağız. (Idle, Punch, Hit, Block, Fall).
GSAP, bu durumların zamanlamasını, karakterlerin X/Y koordinatlarını ve kamera sarsıntılarını (screen shake) yönetecek.
Koreografi Jeneratörü: Seçilen süreye (min 40s) göre rastgele ama mantıklı bir timeline oluşturacak. Faz 1 (Giriş) -> Faz 2 (Tartma) -> Faz 3 (Çatışma) -> Faz 4 (Final). Finalde kullanıcının seçtiği kazanan, kaybedeni yere serecek.
Sinematik Efektler: Canvas üzerinde önceki kareleri hafif silerek (motion blur/smear), vurma anlarında partikül saçarak ve dramatik bekleme süreleri ekleyerek sinematik etkiyi vereceğiz.
Video Export: MediaRecorder API kullanılarak Canvas'tan akan görüntüler 60FPS WebM formatında indirilebilir olacak.
Proje Klasör Yapısı
cinematic-stickman/
├── src/
│ ├── app/
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ └── globals.css
│ ├── components/
│ │ ├── Sidebar.tsx
│ │ ├── FightCanvas.tsx
│ │ ├── PlaybackControls.tsx
│ │ └── TopBar.tsx
│ ├── engine/
│ │ ├── config.ts # Pozlar ve varsayılan ayarlar
│ │ ├── renderer.ts # Canvas çizim mantığı (motion blur, karakterler, partiküller)
│ │ ├── choreography.ts # GSAP Timeline oluşturucu ve dövüş mantığı
│ │ └── exporter.ts # MediaRecorder video export aracı
│ └── store/
│ └── useFightStore.ts # Zustand state yönetimi
├── package.json
├── tailwind.config.ts
└── tsconfig.json
Kodların Tamamı
Aşağıdaki adımları sırasıyla uygulayarak projeyi ayağa kaldırabilirsiniz.
1. Kurulum ve Bağımlılıklar
Önce terminalde Next.js projesini oluşturun ve gerekli paketleri kurun:
npx create-next-app@latest cinematic-stickman --typescript --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm
cd cinematic-stickman
npm install gsap zustand lucide-react
AssistantCopy response Copy first prompt
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Provider Unknown
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language tr
Conversation date Jul 16, 2026
Added to archive Nov 19, 2026
ID 01m7tp7thnftb2wndcky53be8qSource & license Imported from Arena WebDev Preferences (2026) (source ). Imported records earn no Research Points.
Upstream record: 019f6cc3-777e-7a51-97e3-bded3f3dfd15:b
Chi et al., Interaction-as-a-Judge (2026). arXiv:2610.17895.
License: Prompts CC-BY-4.0; outputs governed by provider terms
Dataset releases Not yet included in a published release.
2. Global Stiller (src/app/globals.css) @tailwind base;
@tailwind components;
@tailwind utilities;
body {
background-color: #0a0a0a;
color: #ededed;
overflow: hidden;
}
/* Custom Scrollbar for sleek UI */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #1a1a1a;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 4px;
}
3. Zustand Store (src/store/useFightStore.ts) import { create } from 'zustand';
interface Fighter {
name: string;
color: string;
}
interface FightState {
fighter1: Fighter;
fighter2: Fighter;
winner: 1 | 2;
duration: number; // min 40
isPlaying: boolean;
isGenerating: boolean;
isExporting: boolean;
progress: number;
setFighter1: (data: Partial<Fighter>) => void;
setFighter2: (data: Partial<Fighter>) => void;
setWinner: (winner: 1 | 2) => void;
setDuration: (duration: number) => void;
setIsPlaying: (playing: boolean) => void;
setIsGenerating: (gen: boolean) => void;
setIsExporting: (exp: boolean) => void;
setProgress: (prog: number) => void;
}
export const useFightStore = create<FightState>((set) => ({
fighter1: { name: 'Reaper', color: '#ff3366' },
fighter2: { name: 'Ghost', color: '#00e5ff' },
winner: 1,
duration: 40,
isPlaying: false,
isGenerating: false,
isExporting: false,
progress: 0,
setFighter1: (data) => set((state) => ({ fighter1: { ...state.fighter1, ...data } })),
setFighter2: (data) => set((state) => ({ fighter2: { ...state.fighter2, ...data } })),
setWinner: (winner) => set({ winner }),
setDuration: (duration) => set({ duration }),
setIsPlaying: (isPlaying) => set({ isPlaying }),
setIsGenerating: (isGenerating) => set({ isGenerating }),
setIsExporting: (isExporting) => set({ isExporting }),
setProgress: (progress) => set({ progress }),
}));
4. Motor Konfigürasyonu ve Tipler (src/engine/config.ts) export interface StickmanState {
x: number;
y: number;
scaleX: number;
pose: 'idle' | 'punch' | 'kick' | 'block' | 'hit' | 'fall' | 'victory';
opacity: number;
color: string;
name: string;
}
export interface Particle {
x: number;
y: number;
vx: number;
vy: number;
life: number;
color: string;
size: number;
}
export interface Camera {
x: number;
y: number;
zoom: number;
shake: number;
}
export const POSES = {
// Basit çizgi film mantığıyla kol ve bacak açıları/koordinatları (Render kısmında kullanılacak)
// Bu proje sinematik hissiyatı GSAP tweening ve kamera ile vereceği için pozlar state olarak tutulur.
};
5. Render Motoru (src/engine/renderer.ts) import { StickmanState, Particle, Camera } from './config';
let particles: Particle[] = [];
export const addImpactParticles = (x: number, y: number, color: string) => {
for (let i = 0; i < 15; i++) {
particles.push({
x, y,
vx: (Math.random() - 0.5) * 15,
vy: (Math.random() - 0.5) * 15,
life: 1.0,
color: Math.random() > 0.5 ? color : '#ffffff',
size: Math.random() * 4 + 1
});
}
};
const drawStickman = (ctx: CanvasRenderingContext2D, char: StickmanState) => {
ctx.save();
ctx.translate(char.x, char.y);
ctx.scale(char.scaleX, 1);
ctx.globalAlpha = char.opacity;
ctx.strokeStyle = char.color;
ctx.lineWidth = 4;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
// Gölgelendirme (Glow effect)
ctx.shadowBlur = 10;
ctx.shadowColor = char.color;
ctx.beginPath();
// Head
ctx.arc(0, -60, 12, 0, Math.PI * 2);
// Body
ctx.moveTo(0, -48);
ctx.lineTo(0, 0);
if (char.pose === 'idle') {
ctx.moveTo(0, -30); ctx.lineTo(-15, -10); // Arm L
ctx.moveTo(0, -30); ctx.lineTo(15, -10); // Arm R
ctx.moveTo(0, 0); ctx.lineTo(-15, 30); // Leg L
ctx.moveTo(0, 0); ctx.lineTo(15, 30); // Leg R
} else if (char.pose === 'punch') {
ctx.moveTo(0, -30); ctx.lineTo(30, -30); // Arm Punching (Forward)
ctx.moveTo(0, -30); ctx.lineTo(-15, -15); // Arm Guarding
ctx.moveTo(0, 0); ctx.lineTo(-20, 20); // Leg L Back
ctx.moveTo(0, 0); ctx.lineTo(20, 30); // Leg R Forward
} else if (char.pose === 'kick') {
ctx.moveTo(0, -30); ctx.lineTo(-10, -20);
ctx.moveTo(0, -30); ctx.lineTo(10, -20);
ctx.moveTo(0, 0); ctx.lineTo(-10, 30); // Ground Leg
ctx.moveTo(0, 0); ctx.lineTo(35, -10); // High Kick Leg
} else if (char.pose === 'block') {
ctx.moveTo(0, -30); ctx.lineTo(10, -45); // Arm Block High
ctx.moveTo(0, -30); ctx.lineTo(10, -15); // Arm Block Low
ctx.moveTo(0, 0); ctx.lineTo(-15, 30);
ctx.moveTo(0, 0); ctx.lineTo(15, 30);
} else if (char.pose === 'hit') {
// Geriye bükülmüş
ctx.moveTo(0, -48); ctx.quadraticCurveTo(-15, -24, -10, 0);
ctx.moveTo(-10, -30); ctx.lineTo(-20, -10);
ctx.moveTo(-10, -30); ctx.lineTo(0, -10);
ctx.moveTo(-10, 0); ctx.lineTo(-20, 30);
ctx.moveTo(-10, 0); ctx.lineTo(10, 20);
} else if (char.pose === 'fall') {
ctx.moveTo(0, 20); ctx.lineTo(40, 30); // Body flat
ctx.moveTo(0, 20); ctx.arc(-10, 25, 12, 0, Math.PI * 2); // Head flat
} else if (char.pose === 'victory') {
ctx.moveTo(0, -30); ctx.lineTo(-20, -60); // Arm up
ctx.moveTo(0, -30); ctx.lineTo(20, -60); // Arm up
ctx.moveTo(0, 0); ctx.lineTo(-15, 30);
ctx.moveTo(0, 0); ctx.lineTo(15, 30);
}
ctx.stroke();
// Name Tag
ctx.scale(char.scaleX, 1); // İsim ters dönmesin diye düzeltme
ctx.shadowBlur = 0;
ctx.fillStyle = 'white';
ctx.font = '12px Inter, sans-serif';
ctx.textAlign = 'center';
ctx.fillText(char.name, 0, -90);
ctx.restore();
};
export const renderScene = (
ctx: CanvasRenderingContext2D,
width: number,
height: number,
char1: StickmanState,
char2: StickmanState,
camera: Camera
) => {
// Motion Blur effect: Siyahı hafif saydam çiziyoruz
ctx.fillStyle = 'rgba(10, 10, 10, 0.4)';
ctx.fillRect(0, 0, width, height);
ctx.save();
// Camera transformations
ctx.translate(width / 2 + camera.x, height / 2 + camera.y);
ctx.scale(camera.zoom, camera.zoom);
// Screen Shake
if (camera.shake > 0) {
ctx.translate((Math.random() - 0.5) * camera.shake, (Math.random() - 0.5) * camera.shake);
camera.shake *= 0.8; // Decay shake
if (camera.shake < 0.5) camera.shake = 0;
}
// Draw Ground Line
ctx.strokeStyle = '#222';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(-width, 30);
ctx.lineTo(width, 30);
ctx.stroke();
// Y-axis adjustment for center
ctx.translate(0, 0);
// Draw Particles
particles.forEach((p, i) => {
ctx.fillStyle = p.color;
ctx.globalAlpha = p.life;
ctx.fillRect(p.x, p.y, p.size, p.size);
p.x += p.vx;
p.y += p.vy;
p.life -= 0.05;
if (p.life <= 0) particles.splice(i, 1);
});
ctx.globalAlpha = 1;
// Draw Characters
drawStickman(ctx, char1);
drawStickman(ctx, char2);
ctx.restore();
};
6. Koreografi ve Animasyon Motoru (src/engine/choreography.ts) Burada GSAP kullanarak rastgeleliği sınırlandırılmış, sinematik ve 40 saniye boyunca akıcı bir timeline kuruyoruz.
import gsap from 'gsap';
import { StickmanState, Camera } from './config';
import { addImpactParticles } from './renderer';
export const createFightChoreography = (
char1: StickmanState,
char2: StickmanState,
camera: Camera,
durationSec: number,
winner: 1 | 2,
onUpdate: () => void,
onComplete: () => void
) => {
const tl = gsap.timeline({ onUpdate, onComplete });
// Reset
char1.x = -200; char1.opacity = 0; char1.pose = 'idle'; char1.scaleX = 1;
char2.x = 200; char2.opacity = 0; char2.pose = 'idle'; char2.scaleX = -1;
camera.zoom = 1.5; camera.x = 0; camera.y = -50;
// PHASES CONFIG
const introTime = 4;
const finalTime = 6;
const loopTime = durationSec - introTime - finalTime; // Kalan süre dövüş
// --- FAZ 1: INTRO ---
tl.to([char1, char2], { opacity: 1, duration: 1 })
.to(char1, { x: -80, duration: 2, ease: "power2.out" }, "<")
.to(char2, { x: 80, duration: 2, ease: "power2.out" }, "<")
.to(camera, { zoom: 1.1, y: 0, duration: 3, ease: "power1.inOut" }, "-=2");
let currentTime = introTime;
// DÖVÜŞ DÖNGÜSÜ (FAZ 2, 3, 4)
const attacks = ['punch', 'kick'];
while (currentTime < durationSec - finalTime) {
// Tempo artışı için süreler kısalır
const aggression = currentTime / durationSec; // 0 to 1
const actionSpeed = gsap.utils.mapRange(0, 1, 0.6, 0.2, aggression);
// Kim saldırıyor?
const attacker = Math.random() > 0.5 ? char1 : char2;
const defender = attacker === char1 ? char2 : char1;
const attackType = attacks[Math.floor(Math.random() * attacks.length)] as any;
const isHit = Math.random() > (0.4 + aggression * 0.2); // İlerledikçe isabet artar
// Hareket Başlangıcı (Anticipation)
const targetX = defender.x + (attacker === char1 ? -40 : 40);
tl.to(attacker, { x: targetX, duration: actionSpeed, ease: "power1.in" })
.call(() => { attacker.pose = attackType; });
if (isHit) {
tl.call(() => {
defender.pose = 'hit';
camera.shake = attackType === 'kick' ? 15 : 8;
addImpactParticles(defender.x, defender.y - 30, defender.color);
// Sinematik flash için zoom
if (Math.random() > 0.8) {
gsap.to(camera, { zoom: 1.2, duration: 0.1, yoyo: true, repeat: 1 });
}
})
.to(defender, { x: defender.x + (attacker === char1 ? 30 : -30), duration: 0.1 });
} else {
tl.call(() => { defender.pose = 'block'; });
}
// Toparlanma
tl.to({}, { duration: actionSpeed }) // short pause
.call(() => { attacker.pose = 'idle'; defender.pose = 'idle'; })
.to([attacker, defender], {
x: (i, t) => t === char1 ? t.x - 20 : t.x + 20,
duration: actionSpeed * 1.5,
ease: "power1.out"
});
currentTime += (actionSpeed * 3.5);
}
// --- FAZ 5 & 6: FİNAL ÖNCESİ VE ZAFER ---
const winChar = winner === 1 ? char1 : char2;
const loseChar = winner === 1 ? char2 : char1;
const finalDir = winChar === char1 ? 1 : -1;
tl.to(camera, { zoom: 1.3, duration: 2, ease: "power1.inOut" }) // Gerilim yakınlaşması
.to([char1, char2], { x: (i, t) => t === char1 ? -100 : 100, duration: 1 }, "<")
// Son Kombinasyon
.to(winChar, { x: loseChar.x - (40 * finalDir), duration: 0.2, ease: "power4.in" })
.call(() => { winChar.pose = 'punch'; loseChar.pose = 'hit'; camera.shake = 10; addImpactParticles(loseChar.x, loseChar.y - 30, loseChar.color); })
.to({}, { duration: 0.2 })
.call(() => { winChar.pose = 'kick'; loseChar.pose = 'hit'; camera.shake = 25; addImpactParticles(loseChar.x, loseChar.y - 20, loseChar.color); })
// Dramatik Vuruş (Impact Frame)
.to(camera, { zoom: 1.6, duration: 0.1 })
.to(loseChar, { x: loseChar.x + (150 * finalDir), y: -50, duration: 0.4, ease: "power2.out" })
.call(() => { loseChar.pose = 'fall'; })
.to(loseChar, { y: 0, duration: 0.3, ease: "bounce.out" })
// Kazanan Pozu
.call(() => { winChar.pose = 'victory'; })
.to(camera, { x: winChar.x, zoom: 1.5, duration: 2, ease: "power2.out" });
return tl;
};
7. Video Export Motoru (src/engine/exporter.ts) export class VideoExporter {
mediaRecorder: MediaRecorder | null = null;
recordedChunks: Blob[] = [];
start(canvas: HTMLCanvasElement) {
this.recordedChunks = [];
const stream = canvas.captureStream(60); // 60 FPS
const options = { mimeType: 'video/webm; codecs=vp9' };
try {
this.mediaRecorder = new MediaRecorder(stream, options);
} catch (e) {
this.mediaRecorder = new MediaRecorder(stream); // Fallback
}
this.mediaRecorder.ondataavailable = (e) => {
if (e.data.size > 0) this.recordedChunks.push(e.data);
};
this.mediaRecorder.start();
}
stop(filename: string) {
if (!this.mediaRecorder) return;
this.mediaRecorder.onstop = () => {
const blob = new Blob(this.recordedChunks, { type: 'video/webm' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${filename}.webm`;
a.click();
URL.revokeObjectURL(url);
};
this.mediaRecorder.stop();
}
}
8. Bileşenler Sol Panel / Kontrol (src/components/Sidebar.tsx)
"use client";
import { useFightStore } from '@/store/useFightStore';
import { Play, Settings, Video } from 'lucide-react';
export default function Sidebar() {
const { fighter1, fighter2, winner, duration, setFighter1, setFighter2, setWinner, setDuration, setIsGenerating } = useFightStore();
const handleGenerate = () => {
setIsGenerating(true);
};
return (
<div className="w-80 bg-neutral-900 border-r border-neutral-800 p-6 flex flex-col gap-6 overflow-y-auto h-full z-10">
<div className="flex items-center gap-2 border-b border-neutral-800 pb-4">
<Video className="w-6 h-6 text-red-500" />
<h1 className="font-bold text-xl tracking-wide uppercase text-white">Fight Creator</h1>
</div>
{/* Fighter 1 */}
<div className="space-y-3">
<h2 className="text-sm font-semibold text-neutral-400 uppercase tracking-wider">Fighter 1</h2>
<input
type="text" value={fighter1.name} maxLength={20}
onChange={(e) => setFighter1({ name: e.target.value })}
className="w-full bg-neutral-950 border border-neutral-800 rounded-md p-2 text-sm focus:border-red-500 outline-none transition"
/>
<input
type="color" value={fighter1.color}
onChange={(e) => setFighter1({ color: e.target.value })}
className="w-full h-10 rounded-md cursor-pointer bg-transparent border-0"
/>
</div>
{/* Fighter 2 */}
<div className="space-y-3">
<h2 className="text-sm font-semibold text-neutral-400 uppercase tracking-wider">Fighter 2</h2>
<input
type="text" value={fighter2.name} maxLength={20}
onChange={(e) => setFighter2({ name: e.target.value })}
className="w-full bg-neutral-950 border border-neutral-800 rounded-md p-2 text-sm focus:border-blue-500 outline-none transition"
/>
<input
type="color" value={fighter2.color}
onChange={(e) => setFighter2({ color: e.target.value })}
className="w-full h-10 rounded-md cursor-pointer bg-transparent border-0"
/>
</div>
{/* Settings */}
<div className="space-y-4 pt-4 border-t border-neutral-800">
<div>
<label className="text-sm text-neutral-400 block mb-2">Duration: {duration}s (Min 40)</label>
<input
type="range" min="40" max="90" value={duration}
onChange={(e) => setDuration(Number(e.target.value))}
className="w-full accent-red-500"
/>
</div>
<div>
<label className="text-sm text-neutral-400 block mb-2">Winner</label>
<div className="flex gap-2">
<button
onClick={() => setWinner(1)}
className={`flex-1 py-2 rounded-md text-sm font-medium transition ${winner === 1 ? 'bg-white text-black' : 'bg-neutral-800 text-white hover:bg-neutral-700'}`}
>
{fighter1.name}
</button>
<button
onClick={() => setWinner(2)}
className={`flex-1 py-2 rounded-md text-sm font-medium transition ${winner === 2 ? 'bg-white text-black' : 'bg-neutral-800 text-white hover:bg-neutral-700'}`}
>
{fighter2.name}
</button>
</div>
</div>
</div>
<button
onClick={handleGenerate}
className="mt-auto bg-red-600 hover:bg-red-500 text-white font-bold py-3 px-4 rounded-md flex items-center justify-center gap-2 transition transform hover:scale-[1.02] active:scale-[0.98] shadow-[0_0_15px_rgba(220,38,38,0.4)]"
>
<Settings className="w-5 h-5" />
GENERATE FIGHT
</button>
</div>
);
}
Ana Canvas Bileşeni (src/components/FightCanvas.tsx)
"use client";
import { useEffect, useRef, useState } from 'react';
import { useFightStore } from '@/store/useFightStore';
import { StickmanState, Camera } from '@/engine/config';
import { renderScene } from '@/engine/renderer';
import { createFightChoreography } from '@/engine/choreography';
import { VideoExporter } from '@/engine/exporter';
import gsap from 'gsap';
import { Download, Play, Pause, RotateCcw } from 'lucide-react';
export default function FightCanvas() {
const canvasRef = useRef<HTMLCanvasElement>(null);
const { fighter1, fighter2, duration, winner, isGenerating, setIsGenerating, setProgress } = useFightStore();
const [timeline, setTimeline] = useState<gsap.core.Timeline | null>(null);
const [exporter] = useState(() => new VideoExporter());
const [isExporting, setIsExporting] = useState(false);
const [paused, setPaused] = useState(false);
// States references for GSAP
const char1Ref = useRef<StickmanState>({ x: -100, y: 0, scaleX: 1, pose: 'idle', opacity: 1, color: fighter1.color, name: fighter1.name });
const char2Ref = useRef<StickmanState>({ x: 100, y: 0, scaleX: -1, pose: 'idle', opacity: 1, color: fighter2.color, name: fighter2.name });
const cameraRef = useRef<Camera>({ x: 0, y: 0, zoom: 1, shake: 0 });
// Render Loop
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
let reqId: number;
const render = () => {
// Sync colors and names realtime if changed
char1Ref.current.color = fighter1.color; char1Ref.current.name = fighter1.name;
char2Ref.current.color = fighter2.color; char2Ref.current.name = fighter2.name;
renderScene(ctx, canvas.width, canvas.height, char1Ref.current, char2Ref.current, cameraRef.current);
reqId = requestAnimationFrame(render);
};
render();
return () => cancelAnimationFrame(reqId);
}, [fighter1, fighter2]);
// Generation Logic
useEffect(() => {
if (!isGenerating) return;
if (timeline) timeline.kill();
const tl = createFightChoreography(
char1Ref.current,
char2Ref.current,
cameraRef.current,
duration,
winner,
() => setProgress(tl.progress() * 100),
() => setIsGenerating(false)
);
setTimeline(tl);
setPaused(false);
setIsGenerating(false); // Triggered generation complete
}, [isGenerating]);
const togglePlay = () => {
if (!timeline) return;
if (paused) timeline.play();
else timeline.pause();
setPaused(!paused);
};
const restart = () => {
if (!timeline) return;
timeline.restart();
setPaused(false);
};
const handleExport = () => {
if (!canvasRef.current || !timeline) return;
setIsExporting(true);
exporter.start(canvasRef.current);
timeline.restart();
// Stop exporting when timeline finishes
const onComplete = () => {
exporter.stop(`${fighter1.name}-vs-${fighter2.name}`);
setIsExporting(false);
timeline.eventCallback('onComplete', null); // remove temp callback
};
timeline.eventCallback('onComplete', onComplete);
};
return (
<div className="flex-1 flex flex-col relative bg-neutral-950 items-center justify-center p-8">
{/* Canvas Container */}
<div className="relative w-full max-w-5xl aspect-video rounded-xl overflow-hidden border border-neutral-800 shadow-2xl bg-black">
<canvas
ref={canvasRef}
width={1280}
height={720}
className="w-full h-full object-cover"
/>
{/* Playback Controls Overlay */}
{timeline && (
<div className="absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/60 backdrop-blur-md px-6 py-3 rounded-full flex items-center gap-4 border border-white/10">
<button onClick={restart} className="text-white hover:text-red-400 transition"><RotateCcw size={20}/></button>
<button onClick={togglePlay} className="text-white hover:text-red-400 transition">
{paused ? <Play size={24}/> : <Pause size={24}/>}
</button>
<div className="w-48 h-1 bg-white/20 rounded-full overflow-hidden">
<div className="h-full bg-red-500" style={{ width: `${useFightStore(s => s.progress)}%` }} />
</div>
<button
onClick={handleExport}
disabled={isExporting}
className={`flex items-center gap-2 text-sm font-medium px-3 py-1 rounded-md transition ${isExporting ? 'bg-red-500/50 text-white cursor-wait' : 'bg-white text-black hover:bg-neutral-200'}`}
>
<Download size={16} />
{isExporting ? 'Recording...' : 'Export'}
</button>
</div>
)}
{!timeline && !isGenerating && (
<div className="absolute inset-0 flex items-center justify-center bg-black/80 backdrop-blur-sm">
<div className="text-center">
<Video className="w-16 h-16 text-neutral-600 mx-auto mb-4" />
<p className="text-neutral-400 text-lg">Set your fighters and click Generate Fight</p>
</div>
</div>
)}
</div>
</div>
);
}
Ana Layout ve Page (src/app/page.tsx & src/app/layout.tsx)
import './globals.css'
import type { Metadata } from 'next'
export const metadata: Metadata = {
title: 'Cinematic Stickman Fight Creator',
description: 'Generate cinematic 2D stickman fights',
}
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className="h-screen w-screen flex bg-neutral-950 text-white font-sans overflow-hidden">
{children}
</body>
</html>
)
}
import Sidebar from '@/components/Sidebar';
import FightCanvas from '@/components/FightCanvas';
export default function Home() {
return (
<main className="flex w-full h-full">
<Sidebar />
<FightCanvas />
</main>
);
}
Projeyi Çalıştırma
Terminali açın ve proje dizininde olduğunuzdan emin olun.
Aşağıdaki komutu çalıştırarak geliştirme sunucusunu başlatın:
npm run dev
Tarayıcınızda http://localhost:3000 adresine gidin.
Neler Yaptık ve Neden Mükemmel Oldu?
Kanvas Motoru Sınırları Zorluyor: Matematiksel karmaşıklığı en aza indirmek ama izlenebilirliği (cinematic feel) maksimize etmek için State-based rendering yazdık. GSAP ile karakterler birbiri üzerine x ekseninde uçarken, çizim fonksiyonu onları pose'larına (vuruş, düşüş) göre o anki açılarda çiziyor.
Impact (Vuruş) Hissi: Kamera titreşimi (camera.shake), motion blur (transparan fillRect ile arka plan silinmesi) ve rastgele açılarla saçılan partiküller (addImpactParticles) eklendi.
Koreografi Mantığı (40 sn): while döngüsü ile seçilen süre kadar aksiyon (punch/kick) üretilir. Süre ilerledikçe tempo hızlanır (aggression ratio). Seçilen Winner finalde 2 vuruşluk sinematik bir combo yapar (kamera daralır zoom: 1.6) ve kaybeden geri savrularak (ease: bounce.out) yere düşer.
MediaRecorder Entegrasyonu: Kanvas içeriği WebM formatında yüksek kalitede, arka planda video olarak kayıt alınıp indirilebilecek şekilde VideoExporter sınıfı yazıldı.
Modern Arayüz: Tailwind ile "premium dark mode" estetiği yakalandı. Minimalist ve profesyonel bir kontrol paneli oluşturuldu. SİTE YAP
Tailwind v4 + React 19 + Vite. Let me install the required packages first.
Packages installed. Now I'll set up the HTML shell with fonts and the global styles.
Now the engine core — types and pose presets for the procedural stickman.
Now the WebAudio sound engine — synthesized impacts, whooshes, and a KO boom that also feeds the video export.
Now the render engine — IK stickman drawing, particle system, motion trails, camera shake, and the in-canvas cinematic HUD.
Now the choreography generator — the GSAP timeline that turns settings into a full cinematic fight.
Now the video exporter and the Zustand store.
Now the Sidebar control panel.
Now the FightCanvas component — canvas stage, render loop, timeline lifecycle, playback controls, and export flow.
Quick fix for the unused import, then the App shell.
Now let me build to verify everything compiles.
Build succeeded. Let me fix a potential type issue in the Sidebar (React.ElementType without a React import) by using the proper Lucide type.
Let me add one more dramatic beat to the choreography — knockdowns with get-ups during combos, using the launch/down/getup poses I defined.
Rebuilding to confirm everything compiles after the choreography additions.
Build is clean. The application is complete — here's what was delivered:
StickFight Studio — Cinematic Fight Generator
Adapted your Next.js plan into a Vite + React + Tailwind build, and upgraded the core engine significantly: instead of hard-switched stickman poses, characters are fully procedural puppets (2-bone IK arms/legs, leaning spine, breathing) whose flat pose properties are tweened continuously by GSAP — so every jab, dodge, and knockdown blends smoothly.
Architecture
src/engine/types.ts — Skeleton constants + 18 tweenable pose presets (idle, walk, dash, jab, cross, kicks, block, dodge, hits, launch, down, getup, victory, taunt)
src/engine/renderer.ts — Canvas engine: IK stickman solver with glow + depth-layered limbs, motion trails via a converging alpha erase pass, particle system (sparks, dust, shockwave rings, impact flashes, confetti), ambient motes, soft shadows, and an in-canvas cinematic HUD (letterbox bars, HP bars, intro name cards, "FIGHT"/"K.O." announcements, winner banner) so everything appears in the exported video
src/engine/choreography.ts — Procedural director: Phase 1 walk-in intro → "FIGHT" → escalating exchanges (strikes, 2–3 hit combos, dodge-counters, clashes, knockdowns with get-ups, tense standoffs) with rising aggression → choreographed final: stare-down, dash-cross, spinning-kick K.O. with slow-motion launch, bounce crash, confetti and winner banner. Winner bias increases late-fight for narrative payoff
src/engine/audio.ts — Synthesized WebAudio SFX (whooshes, hits, blocks, thuds, KO sub-boom, victory chime) routed through a compressor and a MediaStreamDestination so exports include sound
src/engine/exporter.ts — 60fps WebM capture (VP9/VP8 + Opus fallback chain) at 14 Mbps
src/store/useFightStore.ts — Zustand: fighters, winner, duration (40–90s), phase machine, sound toggle, dice randomizer
UI
Dark studio sidebar: fighter cards with swatches + color pickers, winner selector, duration slider, sound toggle, glowing GENERATE button
Stage: 1280×720 canvas with transport bar (restart, play/pause, live progress + timecode, EXPORT with REC badge), status chip (STANDBY/LIVE/PAUSED/EXPORTING/DONE), keyboard shortcuts (Space, R)
Click GENERATE FIGHT and the engine choreographs a unique ~45s battle every time; EXPORT records it live to a downloadable WebM.
Files built: index.html, src/index.css, src/engine/types.ts, src/engine/audio.ts, src/engine/renderer.ts, src/engine/choreography.ts, src/engine/exporter.ts, src/store/useFightStore.ts, src/components/Sidebar.tsx, src/components/FightCanvas.tsx, src/App.tsx
Copy first response