Improve gameplay

This commit is contained in:
Andras Schmelczer 2026-06-11 20:26:44 +01:00
parent 7412bc8af5
commit 793d9a81e8
27 changed files with 275 additions and 226 deletions

View file

@ -4,11 +4,14 @@ import { Command } from '../../command';
@serializable
export class PrimaryActionCommand extends Command {
public constructor(public readonly position: vec2) {
public constructor(
public readonly position: vec2,
public readonly charge: number = 0,
) {
super();
}
public toArray(): Array<any> {
return [this.position];
return [this.position, this.charge];
}
}

View file

@ -1,14 +0,0 @@
import { vec2 } from 'gl-matrix';
import { serializable } from '../../../serialization/serializable';
import { Command } from '../../command';
@serializable
export class SecondaryActionCommand extends Command {
public constructor(public readonly position: vec2) {
super();
}
public toArray(): Array<any> {
return [this.position];
}
}

View file

@ -0,0 +1,5 @@
import { clamp01 } from './clamp';
import { settings } from '../settings';
export const holdDurationToCharge = (heldSeconds: number): number =>
clamp01(heldSeconds / settings.chargeShotFullHoldSeconds);

View file

@ -16,7 +16,6 @@ export * from './commands/command-generator';
export * from './commands/types/actions/move-action';
export * from './commands/types/actions/primary-action';
export * from './commands/types/actions/set-aspect-ratio-action';
export * from './commands/types/actions/secondary-action';
export * from './helper/array';
export * from './helper/last';
export * from './helper/rgb';
@ -24,6 +23,7 @@ export * from './helper/hsl';
export * from './helper/rgb255';
export * from './helper/mix-rgb';
export * from './helper/clamp';
export * from './helper/charge';
export * from './helper/calculate-view-area';
export * from './helper/circle';
export * from './helper/rectangle';

View file

@ -26,13 +26,17 @@ export class CharacterBase extends GameObject {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public onShoot(strength: number) {}
public onShoot(strength: number) { }
public onHitConfirmed() { }
public onKillConfirmed(victimName?: string, streak?: number) { }
public setHealth(health: number) {
this.health = health;
}
public onDie() {}
public onDie() { }
public setKillCount(killCount: number) {
this.killCount = killCount;

View file

@ -13,6 +13,11 @@ export class LampBase extends GameObject {
super(id);
}
// Overridden by LampView (which lerps toward the new colour/brightness); a
// no-op on the wire base.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public setLight(color: vec3, lightness: number) {}
public toArray(): Array<any> {
const { id, center, color, lightness } = this;
return [id, center, color, lightness];

View file

@ -4,6 +4,7 @@ import { settings } from '../../settings';
import { serializable } from '../../serialization/serializable';
import { GameObject } from '../game-object';
import { Id } from '../../communication/id';
import { CharacterTeam } from './character-base';
@serializable
export class PlanetBase extends GameObject {
@ -25,6 +26,8 @@ export class PlanetBase extends GameObject {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public generatedPoints(value: number) {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public onFlipped(team: CharacterTeam) {}
public static createPlanetVertices(
center: vec2,