Trek 24 – A Micro-game

By Ogion

Was8bit challenged us to come up with 24-line games (the limit for the free version of Low Res Coder).

Trek 24 is my 24-line ode to classic BASIC Star Trek games. Can you completely explore this sector of the galaxy and eliminate all the Klingons before they destroy you? You win once the map is all starfields. (But I had to sacrifice the 5 lines of code that identified winning.)

Like Super Star Trek, you maneuver using numbers. Here’s the compass rose that starship captains have been using since the 1960s:

432
501
678

So Mark 1 goes right, Mark 2 goes up and right, Mark 3 goes straight up, Mark 4 goes up and left, and so on.

Mark 0 fires your phasers.

The code is a bit obfuscated to fit within the 24-line limit.

Interested in writing your own 24-line programs? Some tips I’ve discovered:

1. Collapse multiline IF statements:
IF X=0 THEN
Y=1
Z=2
ENDIF
…becomes…
IF X=0 THEN Y=1
IF X=0 THEN Z=2

2. Collapse initialization FOR loops:
FOR X= 1 TO 10
A(X) = RND*10
NEXT X

FOR X =1 TO 10
PRINT A(X);
NEXT X
…becomes…
FOR X=1 TO 10
IF A(X)=0 THEN A(X) = RND*10
PRINT X(A);
NEXT X

3. Offset values from 0 instead of intializing
SHIELDS= 100
SHIELDS = SHIELDS-10
IF SHIELDS <= 0 THEN PRINT “YOU LOSE”
…becomes…
SHIELDS = SHIELDS-10
IF SHIELDS <= -100 THEN PRINT “YOU LOSE”

4. Make arrays larger than necessary to eliminate the need for bounds checking.

5. Tolerate errors; can’t error check all user input and all game conditions.

6. Relentlessly oversimplify. For instance, instead of having Klingons detected when going to a new region, I have them show up in the region you just left—much simpler to code! Instead of detecting collisions, presumably the Klingons warp out of the way when you try to ram them. Etc.

Have fun!

Get LowRes Coder to use this program.

Play homegrown retro games and program your own!