How NetWars Works Chapter 11 of 13, plus appendices

11. Input and menus

How the game reads the keyboard and the mouse, which keys each screen accepts, the pull-down menus and the command line. Most of it is ordinary; a few details (key latches, the two keyboard modes) matter for getting the feel of the controls right.

Two ways of reading the keyboard

The game switches between two keyboard modes:

Key (flight)Read asEffect
↑ ↓ ← → (arrow keys and keypad arrows alike)heldsteering (keyboard mode only)
either Shift / either Ctrlheldthrottle up / down
Spaceheld, and latchedfire while held (every 3rd frame); a tap shorter than a frame still fires once; the mouse button works the same
Enter, Caps Lockonce per pressmissile (single player) / cloak on-off (multiplayer); Enter also accepts on the level and death screens
keypad + / −once per pressradar zoom
F2once per presspause (single player; ignored in multiplayer)
Esconce per pressleave, with the score set to 0 (both modes): single player to the high-score check, multiplayer to the name screen, a spectator to the lobby

In flight no other key does anything (PrtSc still prints the screen). Holding a key makes the keyboard repeat it, so a held Enter or keypad + repeats at the keyboard's repeat rate.

Quirks

The mouse

The screens and their keys

ScreenKeys
title↑/↓ or mouse choose Single or Multi; Enter/click accept; Esc quits the program at once. If the network is missing: an error message, then Esc quits.
instructions ⇄ high scores (alternating every 11 s)Enter start; Esc back to the title; F1 help; the menu bar
select start level↑/↓ (levels 1–8, always starting at 1) or mouse height; Enter play; Esc back
level introduction, level completedEnter/click continue; Esc ends the game (after a level the score, bonus included, still counts for the high-score table)
death screeninput ignored for 64 frames; then Enter/click restart (or straight to the initials after a top-ten score). Esc, even in the first 64 frames, leaves with the score set to 0.
lobby←/→ move between slots (wrapping); Enter/click take a free slot (an occupied one is ignored); letters are menu hotkeys; F1 help; Esc title
name entryup to 15 characters (space allowed); Backspace/Del erase; Enter fly; Esc back to the lobby. It also comes back after every Esc in flight, and shows the scores.
initials entryup to 3 characters (no space); Backspace/Del erase; Enter or Esc store
help pageEsc, Enter or a click closes it
Quirks

The menu bar

The instructions/high-score screens and the lobby show a pull-down menu bar at the top. Each title has a hotkey letter, shown underlined: Game, Controls, Sound, Graphics and, in the lobby, Universe.

MenuItemsEffect
GameStart new game (single) / Spectate current game (multi); Exit this modelike Enter (or spectate); like Esc
ControlsKeyboard, Normal Mouse, Reversed Mousesteering device
SoundNone, PC Speakerchapter 10
GraphicsLines, Polygonschapter 9 (also 64 or 256 stars, 12 or 38 explosion sparks)
Universe (lobby only)1 … 8switch to another universe (chapter 8)

Nothing is saved: the options last until the program ends. The only file the game ever writes is the high-score table, HISCORES.DAT.

Starting and stopping

For a rebuild

Keep a key table with "held" and "latched" per key, filled by keydown/keyup, and let each reader clear the latch it consumes; that reproduces exactly when actions fire. Use typed-key events for text entry. Offer the original keys but avoid browser shortcuts (chapter 13). Remembering the options between sessions (local storage) is a harmless improvement.