49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
// Headless harness: stubs Phaser just enough to load the real game modules
|
|
// (Mining, AsteroidCluster, Ship, Config, Color) and exercise the ore logic.
|
|
class GameObject {
|
|
constructor(scene, x = 0, y = 0) {
|
|
this.scene = scene;
|
|
this.x = x;
|
|
this.y = y;
|
|
this.rotation = 0;
|
|
this.alpha = 1;
|
|
this.scale = 1;
|
|
this.active = true;
|
|
this.children = [];
|
|
}
|
|
add(obj) { this.children.push(obj); return this; }
|
|
remove(obj) { this.children = this.children.filter((c) => c !== obj); return this; }
|
|
setDepth() { return this; }
|
|
setAlpha(a) { this.alpha = a; return this; }
|
|
setScale(v) { this.scale = v; return this; }
|
|
setTint(t) { this.tint = t; return this; }
|
|
setBlendMode() { return this; }
|
|
setPosition(x, y) { this.x = x; this.y = y; return this; }
|
|
setStrokeStyle() { return this; }
|
|
destroy() { this.active = false; this.destroyed = true; }
|
|
}
|
|
const Container = class extends GameObject {};
|
|
const Sprite = class extends GameObject {
|
|
constructor(scene, x, y, key, frame) { super(scene, x, y); this.key = key; this.frame = frame; this.body = null; }
|
|
};
|
|
|
|
function hexToRgbInt(v) {
|
|
const m = String(v).trim().match(/^#?([0-9a-f]{6})$/i);
|
|
return m ? parseInt(m[1], 16) : 0xffffff;
|
|
}
|
|
|
|
export default {
|
|
GameObjects: { Container, Sprite },
|
|
Physics: { Arcade: { Sprite } },
|
|
Display: { Color: { ValueToColor: (v) => ({ color: hexToRgbInt(v) }) } },
|
|
Math: {
|
|
Clamp: (v, a, b) => Math.min(b, Math.max(a, v)),
|
|
Linear: (a, b, t) => a + (b - a) * t,
|
|
Angle: {
|
|
Wrap: (a) => a,
|
|
RotateTo: (c, w, s) => (Math.abs(w - c) <= s ? w : c + Math.sign(w - c) * s),
|
|
},
|
|
},
|
|
BlendModes: { ADD: 'ADD' },
|
|
};
|