Add ragdoll physics and reactive camera shake for satisfying slaps
Implement ragdoll physics for agent interactions, including a state machine for falling, getting up, and counter-attacks. Introduce camera shake based on slap impact and export camera shake strength from agents.js. Update main.js to apply camera shake around the renderer. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 418bf6f8-212b-4bb0-a7a5-8231a061da4e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: b80e7d8c-b272-408c-8f8f-e4edd67ca534 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9f85e954-647c-46a5-90a7-396e495a805a/418bf6f8-212b-4bb0-a7a5-8231a061da4e/Q83Uqvu Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -2,7 +2,7 @@ import { initWorld, onWindowResize, disposeWorld } from './world.js';
|
||||
import {
|
||||
initAgents, updateAgents, getAgentCount,
|
||||
disposeAgents, getAgentStates, applyAgentStates,
|
||||
getTimmyGroup, applySlap,
|
||||
getTimmyGroup, applySlap, getCameraShakeStrength,
|
||||
} from './agents.js';
|
||||
import { initEffects, updateEffects, disposeEffects } from './effects.js';
|
||||
import { initUI, updateUI } from './ui.js';
|
||||
@@ -61,7 +61,21 @@ function buildWorld(firstInit, stateSnapshot) {
|
||||
connectionState: getConnectionState(),
|
||||
});
|
||||
|
||||
// Camera shake — apply transient offset, render, then restore (no drift)
|
||||
const shakeStr = getCameraShakeStrength();
|
||||
let sx = 0, sy = 0;
|
||||
if (shakeStr > 0) {
|
||||
const mag = shakeStr * 0.22;
|
||||
sx = (Math.random() - 0.5) * mag;
|
||||
sy = (Math.random() - 0.5) * mag * 0.45;
|
||||
camera.position.x += sx;
|
||||
camera.position.y += sy;
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
if (shakeStr > 0) {
|
||||
camera.position.x -= sx;
|
||||
camera.position.y -= sy;
|
||||
}
|
||||
}
|
||||
|
||||
animate();
|
||||
|
||||
Reference in New Issue
Block a user