بنقرة واحدة
canvas-game-architecture
Patterns for building HTML5 Canvas games with fixed-timestep physics and modular ES modules
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Patterns for building HTML5 Canvas games with fixed-timestep physics and modular ES modules
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | canvas-game-architecture |
| description | Patterns for building HTML5 Canvas games with fixed-timestep physics and modular ES modules |
| domain | game-development |
| confidence | high |
| source | earned |
Applies when building 2D HTML5 Canvas games — especially physics-based games like pinball, breakout, or platformers. These patterns ensure smooth physics, clean architecture, and maintainable code.
Use an accumulator pattern to decouple physics from rendering:
while (accumulator >= PHYSICS_STEP) {
update(PHYSICS_STEP);
accumulator -= PHYSICS_STEP;
}
render();
Physics at 120Hz, rendering at display refresh. Cap frame delta to prevent spiral of death (Math.min(dt, 0.05)).
ball.velocity · wall.oneWayNormal >= 0Contact velocity = angularVelocity × distanceFromPivot, applied perpendicular to flipper. Tip hits harder than base — this makes flipper aim meaningful.
imageSmoothingEnabled = false on contextimage-rendering: pixelated; image-rendering: crisp-edgesMath.floor())dt from requestAnimationFrame directly for physics. Always use fixed timestep.oneWayNormal property instead of hacks.