Skip to content
Game 5 Unit 8 of 128 1 hr learning time

Complete Two-Player Game

Polish pass. Smooth cursor control, better feedback. Hand it to a friend and play.

6% of Ink War

The game is functionally complete. Two players can compete, see who wins, and play again. But there are rough edges — the cursor races across the board if you hold a key, and the results screen doesn’t tell you what to do next.

This unit is a polish pass. Small changes that transform a working prototype into a comfortable game.

Run It

pasmonext --sna inkwar.asm inkwar.sna

Unit 8 Screenshot

Play a game. Notice how the cursor moves at a controlled pace even when holding a direction key. When the game ends, you’ll see “PRESS ANY KEY” so players know what to do.

The Key Repeat Problem

In Unit 7, holding a direction key made the cursor fly across the board. The main loop runs 50 times per second, and every frame with a key held triggered movement. Too fast for precise control.

The solution: key repeat delay. When you press a direction, move immediately. If you hold the key, wait several frames before moving again.

KEY_DELAY sets how many frames to wait between repeats. At 8 frames (about 160ms at 50Hz), the cursor moves at a comfortable pace.

Implementing Key Repeat

The logic tracks the previous key and a countdown timer:

Three cases:

  1. No key pressed: Reset tracking variables
  2. New key pressed: Move immediately, start the timer
  3. Same key held: Decrement timer, only move when it hits zero

Note that Space (claim) bypasses this entirely — you want instant response when claiming a cell.

Results Screen Prompt

Players shouldn’t wonder what to do after the game ends. A simple prompt helps:

Now the flow is clear: see who won, press any key, return to title.

What Makes Polish Matter

These changes are small in code but significant in feel:

  • Controlled movement prevents frustrating overshoots
  • Clear prompts eliminate confusion about what to do next
  • Consistent timing makes the game feel intentional, not accidental

Professional games get these details right. Now yours does too.

Phase 1 Midpoint

Congratulations — you’ve built a complete two-player game. Two humans can sit down, play Ink War competitively, and have a good time. That’s a real achievement.

The remaining Phase 1 units add an AI opponent. When you’re done, you’ll be able to play solo.

The Complete Code

Try This: Adjust Key Repeat Speed

KEY_DELAY   equ     4               ; Faster repeat
KEY_DELAY   equ     12              ; Slower repeat

Find the speed that feels right to you.

Try This: Initial Delay vs Repeat Delay

Many games use a longer delay before the first repeat, then faster repeats after:

KEY_INITIAL_DELAY   equ     15      ; First repeat wait
KEY_REPEAT_DELAY    equ     4       ; Subsequent repeats

Modify the key handling to implement this pattern.

What You’ve Learnt

  • Key repeat delay — Control input timing for smooth movement
  • Timer-based input — Use frame counting to gate actions
  • User feedback — Clear prompts guide players through the game
  • Polish matters — Small details create a professional feel

What’s Next

In Unit 9, we’ll add an AI framework. The computer will start making moves — randomly at first, but it’s the foundation for smarter opponents.

What Changed

Unit 7 → Unit 8