feat: add hex trail puzzle, level editor, and visual design guide

This commit is contained in:
cabinw
2026-09-08 21:45:44 +08:00
commit ef2724bb2e
63 changed files with 15036 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import { segmentHexHit } from './path-math.js';
// Approach, readable contact pause, recoil. Used by both browser and Cocos.
export function collisionPhase(progress, reduced=false){
const t=Math.max(0,Math.min(1,progress));
const distance=t<.42?1-Math.pow(1-t/.42,2):t<.64?1:Math.pow(1-(t-.64)/.36,2);
const impact=t>=.42&&t<.64?Math.sin((t-.42)/.22*Math.PI):0;
return {distance,impact,kick:reduced?0:Math.sin(Math.max(0,t-.42)/.22*Math.PI*2)*impact};
}
// Stop the drawn silhouette at first contact, avoiding visible overlap from collider tolerance.
export function contactPath(points,blocker,radius){
if(!blocker)return points;
for(let i=1;i<points.length;i++){
const a=points[i-1],b=points[i],t=segmentHexHit(a,b,blocker,radius*2);
if(t!==null)return [...points.slice(0,i),{x:a.x+(b.x-a.x)*t,y:a.y+(b.y-a.y)*t}];
}
return points;
}