Add ant brush element with keybinding and GUI entry

This commit is contained in:
Jared Miller 2026-03-11 20:55:48 -04:00
parent c81ecaf21e
commit b8f49afcc4
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
2 changed files with 28 additions and 2 deletions

View file

@ -73,6 +73,7 @@ class GUIController {
"rock (E)": MAT_ROCK,
"food (W)": MAT_FOOD,
"home (Q)": MAT_HOME,
"ants (A)": 999,
};
// proxy object for lil-gui string dropdown — initialize from saved config

View file

@ -15,6 +15,8 @@ import fragmentShaderGround from "../shaders/screenWorld.frag";
import vertexShaderGround from "../shaders/screenWorld.vert";
import AbstractScene from "./AbstractScene";
export const BRUSH_ANTS = 999;
export default class ScreenScene extends AbstractScene {
public readonly camera: THREE.OrthographicCamera;
public readonly material: THREE.ShaderMaterial;
@ -33,11 +35,21 @@ export default class ScreenScene extends AbstractScene {
// resolves active draw mode: key-held takes priority, then GUI brush selection
public get effectiveDrawMode(): number {
if (this.drawMode === BRUSH_ANTS) return -1;
if (this.drawMode >= 0) return this.drawMode;
if (this.isPointerDown && Config.brushMaterial >= 0)
if (this.isPointerDown && Config.brushMaterial >= 0) {
if (Config.brushMaterial === BRUSH_ANTS) return -1;
return Config.brushMaterial;
}
return -1;
}
public get isAntBrushActive(): boolean {
if (this.drawMode === BRUSH_ANTS) return true;
if (this.isPointerDown && Config.brushMaterial === BRUSH_ANTS)
return true;
return false;
}
public renderWidth: number = 1;
public renderHeight: number = 1;
@ -188,6 +200,10 @@ export default class ScreenScene extends AbstractScene {
this.drawMode = MAT_DIRT;
break;
}
case "KeyA": {
this.drawMode = BRUSH_ANTS;
break;
}
case "KeyV": {
Config.viewMode =
Config.viewMode === "side" ? "top" : "side";
@ -276,7 +292,16 @@ export default class ScreenScene extends AbstractScene {
this.renderHeight = height;
}
public update() {}
public update() {
if (this.isAntBrushActive && this.isPointerDown) {
this.antSpawnRequest.set(
this.pointerPosition.x,
this.pointerPosition.y,
Config.brushRadius,
1, // flag: spawn requested
);
}
}
public applyCameraZoom() {
this.updateCameraZoom();