Squash Trainer is a new sports/action videogame for the Sinclair ZX81, coded for the 12th edition of the BASIC 10 Liner Contest. It’s a minimalist 1-player Pong-like game; you can see it in action in this video:
According to the Contest rules for the PUR-80 category, the game has been programmed in 10 lines (max 80 characters per logical line, abbreviations are allowed) for the factory built-in BASIC dialect.
Since the ZX81 BASIC interpreter only allows one statement per line, the program consists of 10 statements. The program uses a string to encode multiple variables; with this technique, it is possible to alter their values with just one statement.
And here is the BASIC listings:
1LET M$="?(X "+CHR$(4*(RND<.5))+"0 ?"
2LET C=(M$(1)="$")*(M$(2)>=M$(8))*(CODE M$(2)-CODE M$(8)<3)
3IF C THEN LET M$(4 TO 7)=" "+CHR$((RND<.5)*4)+STR$(1+VAL M$(6 TO 7))
4LET M$(4)=CHR$((M$(1)>"▀")*CODE M$(4)+4*(M$(1)="▀"))
5LET M$(5)=CHR$((M$(2)>" ")*(M$(2)<"0")*CODE M$(5)+4*(M$(2)=" "))
6PRINT AT CODE M$(1),CODE M$(2);" ";AT14,CODE M$(8);" "
7LET M$(TO3)=CHR$(CODE M$(1)+CODE M$(4)-2)+CHR$(CODE M$(2)+CODE M$(5)-2)+INKEY$
8LET M$(8)=CHR$(CODE M$(8)+3*(M$(3)="P")*(M$(8)<".")-3*(M$(3)="O")*(M$(8)>" "))
9PRINT AT0,0;M$(6TO7);AT CODE M$(1),CODE M$(2);"▇";AT14,CODE M$(8);"░░░"
10GOTO 2*(M$(1)<"?")+20*((M$(1)="?")+(M$(6TO7)="99")>0)
By surfing to the project page on retrobits.itch.io, you can either download an archive containing the game, the source code and the detailed program documentation, or just play Squash Trainer in your web browser, thanks to the online emulator (mobile devices are not supported).
Happy training!
Links and references
- Download or play Squash Trainer online on retrobits.itch.io
- Watch the gameplay video on YouTube
- Play Squash Trainer online on my web site rm-rf
- Surf to the BASIC 10 Liner Contest official site
- Surf to the BASIC 10 Liner Contest on itch.io