Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file.

## [1.36.0] - 2026-11-15

### Added

- Pause and gun-swap buttons are available with a mouse as well as touch. The swap button appears when special guns unlock in sector 3; its charge bar and first-use ring show when and where to switch. Q still works, and touch steering remains independent of the buttons.

### Changed

- Hull Armor now adds 1 HP per tier instead of 2, for 10 HP at the maximum tier instead of 15. The first tier still costs 500 credits after sector 1.
- Shield tiers open after sectors 3, 6 and 9 instead of 3, 5 and 7. High scores cannot skip these limits. Hull and shields still recover between sectors and on respawn; offensive upgrades and enemy patterns are unchanged.
- Older saves keep their purchased upgrade tiers; hull health is clamped to the new maximum when loaded.

## [1.35.1] - 2026-11-14

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ _Avoid_: surprise, cheap shot

## Decisions

**Defensive progression stays bounded even with high scores (2026-11)**:
Score buys upgrades but never advances the campaign or grants level-ups. Chain multipliers and fast-kill bonuses made the defensive caps easy to buy, so Hull Armor now grants one HP per tier (5 base, 10 maximum), and shield tiers open after sectors 3, 6 and 9. The first hull purchase stays affordable at 500 credits. Sector recovery and respawn shields remain deliberate recovery beats; offense and encounter grammar are unchanged. Pointer buttons for pause and special-gun swap appear on all devices, while relative drag and touch autofire remain touch-only.

**Boss fights are authored rotations with a par time (2026-11)**:
Bosses got harder by soaking up more hull, which made late fights long, easy and repetitive. Boss hull no longer scales with sector or with the player's upgrades; each boss has an authored hull and a par time (45-70 s) measured with `bun run balance:bosses`. Difficulty lives in what the boss does: phases at hull thresholds, an ordered (never random) attack rotation per phase, anchors that move the boss between attacks, and escalation of up to 25% faster volleys past par (never a shorter wind-up; the first boss is exempt). A kill under par pays a fixed bonus per second. Fight time is the boss's gameplay clock, so pause and hit-stop never count. Difficulty tiers still only scale accepted hull damage.

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ Open `http://localhost:5173` in your browser.
|-------|--------|
| Arrow keys / WASD | Move ship |
| Space / Click | Fire weapons |
| Q | From sector 3: switch to a special gun while its charge lasts (Lance → Scatter → Seekers → Lance) |
| Esc | Pause (closes the settings sheet on the menu) |
| Q / Swap button | From sector 3: switch to a special gun while its charge lasts (Lance → Scatter → Seekers → Lance) |
| Esc / Pause button | Pause (closes the settings sheet on the menu) |

The ship flies with inertia: it builds speed over about a second and slides after you let go.

On touch devices, drag anywhere to fly: the ship follows your finger's movement and the main gun
fires automatically. Pressing a key on a hardware keyboard hands steering and firing to the
keyboard, and the next touch hands them back (tap-to-pause stays available). From sector 3, a swap
button under the pause button switches guns and shows the special-gun charge.
button under the pause button switches guns and shows the special-gun charge. Both buttons also
accept mouse clicks on desktop and hybrid devices; gun switching appears only when it unlocks.

The refit bay after sector 2 opens with a short SPECIAL GUNS ONLINE card that explains Lance, the
swap key and the charge. In sector 3 the swap is pointed out until you first use it: a
`Q SPECIAL GUN` label beside the HUD charge bar on a keyboard, a pulsing ring around the swap
button on touch.
`Q SPECIAL GUN` label beside the HUD charge bar on a keyboard, and a pulsing ring around the swap
button on every device.

Autofire is set in SETTINGS (menu or pause panel). Touch flight autofires by default; turn it off
to fire only while your finger is on the screen. Keyboard and mouse play can turn autofire on, so
Expand Down Expand Up @@ -116,7 +117,7 @@ Menu → Game → Planet Intermission → Game → ... → Victory

Bought during the planet intermission screen using score as currency:

- **Hull Armor** — raises max HP
- **Hull Armor** — adds 1 max HP per tier, up to 10 HP
- **Weapons** — increases damage
- **Fire Rate** — improves firing speed
- **Shield** — increases hit absorption
Expand Down
13 changes: 12 additions & 1 deletion docs/level-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ shields recharge on every respawn.
Levels 5–10 add payoff without adding player inputs:

- **AEGIS Picket** becomes purchasable after Level 4. Its fixed flank turrets trim chaff with flat-damage bolts while the main gun remains the dominant damage source. Pickets never target bosses.
- **Main guns** (`config/shipSystems.ts`): sectors 1–2 fly the standard bolt and have no gun input, so the opening stays a gentle introduction. From sector 3 the home gun is Lance; Scatter and Seekers are special guns borrowed on a charge, not picks. Each gun trades single-target damage for one strength and scored inside the standard gun's run-to-run spread in sector 5. Q or the touch swap key steps Lance → Scatter → Seekers → Lance. One meter, `SPECIAL_GUN_CHARGE`, counted on the gameplay clock, pays for the specials: it drains while one is selected (a full meter lasts 8 s) and returns the gun to Lance at empty; on Lance it refills over 40 s plus 0.005 per enemy destroyed; leaving Lance needs at least 0.2 of it, while moving between specials or back to Lance is always allowed. It starts full every sector and after every respawn or checkpoint load, and is never saved. Feedback is a name flash over the ship and a short swap sound on every change (including the automatic return), the quiet click when leaving Lance is refused, each gun's own shot look (the profile's `look`), and the HUD's gun row under the reserve ships: the gun's name and a charge bar that burns amber while a special drains and refills cyan on Lance, with a tick at the threshold. The touch swap key mirrors the bar along its foot. The guns are taught, never picked: the refit bay after sector 2 opens on a one-button SPECIAL GUNS ONLINE card (`planetIntermission/specialGunIntro.ts`, shown on every visit to that bay and no other), and sector 3 only points at the swap until the first one there (`ShipSystemsRuntime.isSwapHintPending`): a `Q SPECIAL GUN` label beside the charge bar on a keyboard, a pulsing ring around the touch swap key.
- **Main guns** (`config/shipSystems.ts`): sectors 1–2 fly the standard bolt and have no gun input, so the opening stays a gentle introduction. From sector 3 the home gun is Lance; Scatter and Seekers are special guns borrowed on a charge, not picks. Each gun trades single-target damage for one strength and scored inside the standard gun's run-to-run spread in sector 5. Q or the on-screen swap key steps Lance → Scatter → Seekers → Lance. One meter, `SPECIAL_GUN_CHARGE`, counted on the gameplay clock, pays for the specials: it drains while one is selected (a full meter lasts 8 s) and returns the gun to Lance at empty; on Lance it refills over 40 s plus 0.005 per enemy destroyed; leaving Lance needs at least 0.2 of it, while moving between specials or back to Lance is always allowed. It starts full every sector and after every respawn or checkpoint load, and is never saved. Feedback is a name flash over the ship and a short swap sound on every change (including the automatic return), the quiet click when leaving Lance is refused, each gun's own shot look (the profile's `look`), and the HUD's gun row under the reserve ships: the gun's name and a charge bar that burns amber while a special drains and refills cyan on Lance, with a tick at the threshold. The on-screen swap key mirrors the bar along its foot. The guns are taught, never picked: the refit bay after sector 2 opens on a one-button SPECIAL GUNS ONLINE card (`planetIntermission/specialGunIntro.ts`, shown on every visit to that bay and no other), and sector 3 only points at the swap until the first one there (`ShipSystemsRuntime.isSwapHintPending`): a `Q SPECIAL GUN` label beside the charge bar on a keyboard, a pulsing ring around the on-screen swap key on every device.
- **Ship systems** are free one-of-three picks at the refit bay after sectors 5 and 8. They change how the ship plays rather than how hard it hits. A system works without input; the only input is changing one. Once a slot has a pick the player may change it to another option of that slot: freely at every later refit bay (the picks sit beside the upgrade cards and reopen the pick dialog, which Escape dismisses) and mid-run from the pause panel's SYSTEMS tab. The current pick is saved with the run.
- **Run variation** comes from one seed per run (`systems/runVariation.ts`, `systems/gameplayRandom.ts`). It decides the wave choices, whether each sector is mirrored left to right, and the sky. Two rules keep scores comparable: the sky is looks only, and the only layout change is the mirror, which is as hard by symmetry. Never vary wave order, enemy counts or timing by seed. RETRY keeps the seed; NEW RUN draws a new one. Enemies, asteroids and wormholes each draw from their own seeded stream, so one cannot shift another's choices; how far a run gets through a stream still depends on play. Enemy jitter and pickup drops stay unseeded because they depend on how the fight goes.
- **Marked Aces** are sparse authored variants of existing enemies. Their gilded treatment signals 2× durability, 4× score, and exactly one guaranteed power-up.
Expand Down Expand Up @@ -243,3 +243,14 @@ Solar flares leave a visible bottom escape lane of at least 100px or 22% of view
The campaign pass applies the same pickup travel check to the other six boss levels. Boss triggers are now 0.752 for Clockwork Causeway, 0.746 for Shatter Reef, 0.741 for Hollow Choir, 0.719 for Eclipse Narrows, 0.718 for Swarmfront, and 0.695 for Eventide Engine. Earlier sections and authored wave timestamps stay fixed. The existing finale approach health remains health. Tideglass introduces its first portal with familiar scouts before its dodger line, and keeps ambush combinations for the later section.

These extensions add 43.88s across eight approaches. Each approach lasts about 8s and asks for a deliberate midfield pickup interception. The rejected 103.40s version relied on passive lower-screen collection and added too much waiting. Normal level transitions refill hull and purchased shields; sustained campaign attrition is principally reserves and credits, not carried hull damage.

### Defensive upgrade pacing

Score is also refit currency, and chains can multiply kill income by five. Defensive strength therefore
needs a ceiling even when a high-scoring run can afford every open tier. Hull Armor adds one HP per
tier (5 base, 10 at maximum); its first tier still costs 500 credits after sector 1. Shield tiers open
after sectors 3, 6, and 9. Full hull and purchased shields still return at sector transitions and
respawns. Entering sectors 6, 8, and 10 with every available defensive upgrade now gives 9, 11, and 13
combined hull/shield points, previously 13, 16, and 18. Weapon damage, firing speed, score rewards,
and authored recovery pickups are unchanged. Existing saves keep their tiers; excess hull is bounded
to the new maximum when loaded, and already-owned shield tiers remain owned.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "space-explorer",
"version": "1.35.1",
"version": "1.36.0",
"author": "Douwe de Vries",
"license": "MIT",
"private": true,
Expand Down
6 changes: 3 additions & 3 deletions src/config/UpgradesConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const UPGRADES: UpgradeDef[] = [
{
key: 'hp',
name: 'HULL ARMOR',
description: '+2 Max HP',
description: '+1 Max HP',
maxLevel: 5,
progressionCaps: [1, 2, 2, 3, 3, 4, 4, 5, 5, 5],
baseCost: 500,
Expand Down Expand Up @@ -85,8 +85,8 @@ const UPGRADES: UpgradeDef[] = [
name: 'SHIELD',
description: '+1 Shield each life',
maxLevel: 3,
progressionCaps: [0, 0, 1, 1, 2, 2, 3, 3, 3, 3],
// A shield tier is one absorbed hit per life, where a hull tier is two: priced a little above hull.
progressionCaps: [0, 0, 1, 1, 1, 2, 2, 2, 3, 3],
// Shields absorb a full hit at any difficulty; later tiers open gradually to limit defensive stacking.
baseCost: 1000,
costMultiplier: 2,
unlock: {
Expand Down
2 changes: 1 addition & 1 deletion src/config/playerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const PLAYER_CONFIG = {
// The campaign has no reserve-life upgrades, so this is also the persisted-state maximum.
startingLives: 3,
baseFireRate: 150,
hpPerUpgrade: 2,
hpPerUpgrade: 1,
fireRateReductionPerUpgrade: 15,
minFireRate: 60,
// Hard floor for any fire-rate reduction (rapidfire pickups, max-chain Overdrive).
Expand Down
4 changes: 2 additions & 2 deletions src/scenes/gameScene/gameplayFrameBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ export function createGameSceneGameplayFrameBehavior(
else if (outcome === 'low-charge') delegate.gunSwapFeedback.denied();
}
if (shipSystems.updateGunCharge(delta)) delegate.gunSwapFeedback.swapped('lance');
// Until the first swap of sector 3 the swap is pointed out: a pulse on the touch key, else a Q label.
// Until the first swap of sector 3, pulse the on-screen key and also show Q for keyboard players.
const hint = shipSystems.isSwapHintPending();
const touchHint = hint && (delegate.mobileControls?.showsTouchHints() ?? false);
delegate.mobileControls?.setGunChargeState(shipSystems.getGun(), shipSystems.getGunCharge(), touchHint);
delegate.mobileControls?.setGunChargeState(shipSystems.getGun(), shipSystems.getGunCharge(), hint);
delegate.hud.setSwapHint(hint && !touchHint);
};

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/gameScene/showControlsHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AUTO_FIRE_HINT = 'Guns fire automatically';
const MOBILE_FIRE_HINT = 'Guns fire while you touch';
const KEYBOARD_TITLE = 'WASD / Arrows to Move';
const KEYBOARD_FIRE_HINT = 'SPACE / Click to Fire';
const KEYBOARD_SWAP_HINT = 'Q for a Special Gun';
const KEYBOARD_SWAP_HINT = 'Q / swap button: Special Gun';

/** The fire line follows the autofire setting for the input in use. */
function fireHintFor(mobile: boolean): string {
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/planetIntermission/specialGunIntro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function isSpecialGunIntroDue(clearedLevel: number): boolean {
export function describeSpecialGunIntro(touch: boolean): readonly string[] {
return [
'Your main gun is now the LANCE: slower shots that pierce every ship in a line.',
`${touch ? 'Tap the swap key' : 'Press Q'} to switch to SCATTER or SEEKERS.`,
`${touch ? 'Tap the swap key' : 'Press Q or click the swap key'} to switch to SCATTER or SEEKERS.`,
'Special guns run on a charge. When it is empty you drop back to the Lance, which refills it.',
];
}
Expand Down
3 changes: 2 additions & 1 deletion src/systems/InputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class InputManager {
}

// Keyboard and mouse play can opt in to autofire from settings.
return autoFire.keyboard || this.space.isDown || this.scene.input.activePointer.isDown;
const pointer = this.scene.input.activePointer;
return autoFire.keyboard || this.space.isDown || (pointer.isDown && !mobileControls?.isControlPointer(pointer));
}

/** Touch drag steering velocity for the ship at (x, y), or null when no finger is steering. */
Expand Down
24 changes: 13 additions & 11 deletions src/systems/MobileControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ControlKey {
}

/**
* Touch controls for momentum flight: drag anywhere and the ship follows the finger's movement,
* Pointer buttons for every device, with touch controls for momentum flight: drag anywhere and the ship follows the finger's movement,
* while the main gun autofires. A pause button stays available in the top-right corner, and from sector 3
* a swap button sits under it that borrows a special gun and shows the charge.
*/
Expand Down Expand Up @@ -68,7 +68,13 @@ export class MobileControls {
private readonly handlePointerDown = (pointer: Phaser.Input.Pointer): void => {
// Drag steering is a touch control: trackpad or mouse presses on hybrid devices never start it.
// Suppression is not checked here because this listener runs before the bootstrap's touch restore.
if (!pointer.wasTouch || !this.isEnabled() || this.dragPointerId !== null || this.isOverControlKey(pointer)) {
if (
!pointer.wasTouch ||
!this.enabledForTouchDevice ||
!this.isEnabled() ||
this.dragPointerId !== null ||
this.isOverControlKey(pointer)
) {
return;
}

Expand Down Expand Up @@ -108,10 +114,6 @@ export class MobileControls {
this.enabledForTouchDevice = isTouchMobileDevice();
this.blocked = false;

if (!this.enabledForTouchDevice) {
return this;
}

const extraPointers = Math.max(0, 3 - scene.input.manager.pointersTotal);
if (extraPointers > 0) {
scene.input.addPointer(extraPointers);
Expand Down Expand Up @@ -170,7 +172,7 @@ export class MobileControls {
}

relayout(): void {
if (!this.scene || !this.enabledForTouchDevice) {
if (!this.scene) {
return;
}

Expand Down Expand Up @@ -201,12 +203,12 @@ export class MobileControls {
}

isEnabled(): boolean {
return this.enabledForTouchDevice && !this.blocked && this.scene !== null;
return !this.blocked && this.scene !== null;
}

/** True while touch is the active input; the gun then autofires unless touch autofire is off. */
isTouchSteeringActive(): boolean {
return this.isEnabled() && !this.touchSteeringSuppressed;
return this.enabledForTouchDevice && this.isEnabled() && !this.touchSteeringSuppressed;
}

/** True while the steering finger is on the screen, whatever other fingers tap meanwhile. */
Expand All @@ -216,7 +218,7 @@ export class MobileControls {

isControlPointer(pointer: Phaser.Input.Pointer): boolean {
return (
this.enabledForTouchDevice &&
this.scene !== null &&
(pointer.id === this.pauseButtonPointerId ||
pointer.id === this.swapButtonPointerId ||
pointer.id === this.dragPointerId)
Expand Down Expand Up @@ -320,7 +322,7 @@ export class MobileControls {
}

private refreshVisibility(): void {
const pauseVisible = this.enabledForTouchDevice && this.scene !== null;
const pauseVisible = this.scene !== null;
// The pause panel covers the field, so the swap key hides with it.
const swapVisible = pauseVisible && this.swapAvailable && !this.blocked;
setControlKeyVisible(this.pauseKey, pauseVisible, pauseVisible && !this.blocked);
Expand Down
18 changes: 18 additions & 0 deletions tests/InputManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,21 @@ test('Q and the touch swap button each request one gun swap per press', () => {
expect(manager.consumeGunSwapRequest()).toBe(true);
expect(manager.consumeGunSwapRequest()).toBe(false);
});

test('clicking an on-screen control does not fire the main gun', () => {
autoFire = { touch: true, keyboard: false };
const scene = createScene([]);
let overControl = true;
const inputManager = new InputManager();
inputManager.create(
scene as never,
{
isTouchSteeringActive: () => false,
isControlPointer: () => overControl,
} as never
);
scene.input.activePointer.isDown = true;
expect(inputManager.isFiring()).toBe(false);
overControl = false;
expect(inputManager.isFiring()).toBe(true);
});
Loading
Loading