Route 81 by Marco's Retrobits

Add to
My games
Add to
Wishlist
Save to
Collection
No reviews
Exceptional
Meh
Skip

About

ROUTE81
=======

BASIC 10-Liner videogame for the Sinclair ZX81
==============================================

Marco Varesio ([Marco's Retrobits](https://retrobits.itch.io/))
[English language blog](https://retrobits.altervista.org/)
[Italian language blog](https://somebitsofme.altervista.org)
[YouTube channel](https://www.youtube.com/channel/UCWTxG8paNsOUEU5mPcNklXA)

ROUTE81 is an action game for the Sinclair ZX81 8-bit home computer. 
It is my second entry to the 2021 edition of the BASIC 10 Liner Contest.
The game has been entirely coded in BASIC language and the program is 10 lines long.
Drive your shiny sports car `*` along the most iconic highway in computer history! 
Avoid the other cars `o` and going off the road.
Controls: steer your car with "o" (left) and "p" (right).

Gameplay video:

Play online: https://somebitsofme.altervista.org/rm-rf/site/?p=emu/jtyone&l=2&tzx=emu/soft/zx...

Program description
===================

The player's car occupies the top line of the screen, while the road and the other cars 
scroll up by one line at each iteration of the main game loop. 
Whenever the scrolling occurs, a new road segment (with random horizontal displacement from the previous one) 
and a new opponent car (at random horizontal position within the road segment) are printed at the bottom of the screen. Then the player's car horizontal position is updated based on the pressed key and printed and collision check is performed.

Variables
---------

R: Road segment horizontal position
X: Player's car horizontal position
C: Collision detection

Program listing
---------------

The program is 10 lines long and each line is shorter than 80 characters. 
The most challenging aspect of ZX81 BASIC programming is that the interpreter only allows one statement per line.
In the following listing, which can be used with the ZXText2P tool to make a ".P" file suitable for loading into X81 emulators,
block graphic characters have been replaced with the corresponding escape sequences made up of standard characters.
Therefore, the program looks longer than it actually is. See the ZXText2P documentation for details:
http://freestuff.grok.co.uk/zxtext2p/index.html

1 LET R=11
2 LET X=R+2
3 PRINT AT 21,0;"\.'\.'\.'\.'\.'\.'\.'\.'\.'\.'\.'\.'\.'\.'   \'.\'.\'.\'.\'.\'.\'.\'.\'.\'.\'.\'.\'.\'.\'."
4 LET R=R+(R<20)*RND-(R>2)*RND
5 SCROLL
6 LET X=X+(INKEY$="P")-(INKEY$="O")
7 PRINT AT 21,R;"\##       \##";AT 21,R+1+RND*6; "o";AT 0,X;
8 LET C=(PEEK(PEEK 16398+256*PEEK 16399)<>0)*105
9 PRINT CHR$(23 + C)
10 GO TO 4 + C*10

Source code explained
---------------------

Initializations

The first two lines initialize the road segment horizontal offset R and player's car position X.
Line 3 prints the "start line" at the bottom of the screen.

Game loop

Line 4 calculates the position of the next road segment to be printed, with random displacement from the previous one. 
The program also ensures that the road segment stays within the screen, i.e. the left side of the road segment stays within columns 2 and 20.
Line 5 SCROLLs the display up one line.
Line 6 calculates the new player's car horizontal position, depending on the pressed key. 
If "P" is pressed, the car moves right; if "O" is pressed, the car moves left. 
Line 7 prints at the bottom of the screen (row 21):
* the new road segment at the previously calculated horizontal position R;
* a new opponent car, at a random position within the road sides.
Finally, it sets the print position to the new player's car position.
Line 8 performs collision detection, by reading the value at current print position 
(which corresponds to the new player's car position as effect of the last AT in line 7) in the display file, 
by means of the DF_CC system variable. 
A collision occurs whether the position in which the car will be printed contains a character different than space 
(whose character code is 0); in this case, C is set to 105. Conversely, if there is no collision, C is set to 0. 
C value meaning will be clear by looking at the next statements.
Kudos to [kmurta](http://zx81.eu5.org/) for pointing out that DF_CC system variable can be PEEKed in order to determine what character is  displayed at a particular print position.
Line 9 prints the car at the print position set in line 7, i.e. vertical position 0 (top line) and horizontal position X calculated in line 6.
If a collision occurs (C=105), the printed character is the full block, whose code is 23 + C = 23 + 105 = 128. 
Otherwise, if there is no collision, the printed character is "*", whose code is 23 + C = 23 + 0 = 23.
If no collision occurs, line 10 jumps back to the beginning of the game loop at line 4; 
otherwise, in case of collision, the program jumps to a non-existing line, causing the program to exit with code 0.

Enjoy your drive!

Platforms
Genre
Release date
Developer
BASIC 10Liner
Age rating
Not rated

System requirements for PC

Read more...
Route 81 by Marco's Retrobits screenshot, image №2722452 - RAWG
Edit the game info
Last Modified: Feb 19, 2021

Where to buy

itch.io