Your place is saved automatically on this browser.
Definitive reference build: PHASELOCK v0.13 / PHASELOCK_STAGE_V013_FINAL.zip.
Stage 9 adds the first persistent gameplay consequence to successful movement. The player is now rewarded for forward exploration and penalised for returning to tiles already visited during the current attempt.
Keep visited state separate from levelMap
levelMap continues to describe what a tile is: neutral floor, permanent wall, Blue floor or Amber floor. visitedMap records whether MILO has already occupied that coordinate during the current attempt. Keeping those responsibilities separate avoids mixing level design with temporary player history.
The scoring rules
First visit to a destination tile: +10
Revisit to a previously visited tile: -20The starting tile is stamped as already visited. A score of exactly zero remains valid. CIRCUIT OVERLOAD occurs only when the total becomes negative.
Score only after an approved move
Scoring runs only after attemptMove() has already approved the destination, completed the existing movement animation, updated MILO's logical position and committed the phase change. A rejected wall or phase move therefore cannot alter score or visited state.
Real-hardware failure and the accepted fix
The first v0.13 implementation attempted to clear visitedMap(19,15) with a nested 20×16 loop whenever an attempt began. On real hardware this build showed only the two permanent-wall sprites and then crashed the ZX Spectrum Next. Those walls are created before resetAttempt(), while MILO and the phase-floor sprites are created afterwards, which isolated the failure to the new visited-map reset path.
The accepted build removes the full-array clearing loop. Instead, it uses a visit-generation marker. visitGeneration increments whenever an attempt restarts, and each visited tile stores the current generation number. A tile belongs to the current attempt only when its stored value equals visitGeneration.
This preserves the required gameplay behaviour without clearing all 320 entries and is the approach that should be carried forward.
CIRCUIT OVERLOAD test loop
For this development stage the test starts with three lives. When score becomes negative, CIRCUIT OVERLOAD removes one life and restarts the current test level. The restart returns MILO to the starting tile, resets score to zero, restores Blue phase and increments the visit generation.
The final game-over presentation is not defined by this test harness; only the scoring failure threshold and restart behaviour are being established here.
Stage 9 acceptance
The FIXED2 visit-generation build was accepted on a real ZX Spectrum Next. The final v0.13 historical package therefore preserves that exact working source and the unchanged v0.12 sprite/palette assets.
