A downloadable game

INDY!

==========

Written by David Plass for the BASIC 10-liner Contest 2023

Language: TRS-80 Model 100 BASIC

Category: PUR-80

This and other games are available in my GitHub repo at https://github.com/dplassgit/games

All code in that repo is released under the MIT License.


THE GAME

==========

This is a fun and challenging driving simulation!

Your goal: drive as fast as you can without crashing into the left or right walls of the racetrack!

Control your racecar using the "a" key to move left and the "d" key to move right.

If you can make it through all 10 checkpoints, you win!

But, if you crash, you lose! Restart using "RUN" again.


PROGRAM DESCRIPTION:

==========

Source code is in INDY.DO. It will only run on a Tandy 100 or Tandy 102 laptop or emulator.

0cls:definta-z:s=15:w=11:?"INDY!":?:?"Make it past all 10 checkpoints to win!

Clear screen & print an introduction.

Initialize variables:

  Define variables as integer

  s=left side of the race track

  w=width of the track

1p=c:?:?"Use 'a' to steer left, 'd' for right.":?:?"Hit any key to start...

Simple instructions. Note, Tandy BASIC lets you omit the trailing closing quote of strings.

2c=20:p=c:h=w/2:s$=" ":x$=chr$(132):b$=chr$(255):r!=rnd(peek(63795)):call4811

More variables:

  c=start column of the car

  p=previous column of the car

  h=half the width

  s$=just a space

  x$=the car character

  b$=the "wall" character

  r!=random number seed, via the "seconds" variable

Call 4811 is a ROM routine that waits for the user to hit a key.

3fori=0to110:ifi<10then?tab(s)b$space$(h-2)10-ispace$(h-(i>0)-1)b$:c=s+h:next

The main loop: i=counter for the length of the race

if i<10 then print a "countdown" (10-i)

c=s+h sets the location of the car to the middle of the track.

Note in TRS-80 BASIC you don't even need semicolons between variables 

in a print statement!

4?@p+240,s$;:?@s+280,b$space$(w)b$;:?@c+280,x$;:ifc<=sorc>s+wthen9

If it got here it means we're printing the car too.

Clear the previous (p) location of the car

Draw the left wall at column 's', then 'w' spaces, then the right wall of the track.

Draw the car at its location (c).

If the car hit a wall, it's a crash and you lose, go to line 9.

5ifi>19andimod10=0thenw=w+(i<80):?@285+s+w,"Ck"(i-10)\10:else?

If we're at a checkpoint, decrease the width (w) of the racetrack, unless we're past point 80 (so it doesn't get too small.)

Print the checkpoint number (Ck ##) just past the right side of the track.

6r!=rnd(1):s=s+(r!<.3)-(r!>.7):s=s-(s<0):ifs>=(35-w)thens=35-w

Adjust the left side of the racetrack (s) using a random number (r).

If the random number is less than 0.3, move it left; if it's more than 0.7, move right.

Prevent the start column (s) from being negative and not too close to the right-hand side.

7p=c:d$=inkey$:c=c+(d$="h"ord$="a")-(d$="l"ord$="d")

Save the location of the car, c in p.

Get a key: if the key is h or a, move left. If it's l or d, move right.

(h and l are undocumented keys; they correspond to "move left" and "move right" in vim.)

8next:?@p+240,s$;:?@s+280,b$string$(w,b$)b$;:?@c+280,x$:?"You win!":end

Go to the next counter. 

When the for/next loop is done, it means you haven't crashed, so show a special 

line with the racecar in the middle, and the "You win" message. End the program.

9?:?"CRASH! Final score is:"i-10

If we got here (from line 4) we've crashed. The score is i-10 because the first 10 

steps are just printing the track.

StatusReleased
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
AuthorBASIC 10Liner
GenreRacing
Tagsbasic, basic10liner, model100, tandy, trs-80

Download

Download
description.txt 3.3 kB
Download
indy.do 671 bytes
Download
instructions.txt 376 bytes

Install instructions

1. Open the simulator at http://bitchin100.com/CloudT/#!/M100Display

2. Scroll down and click "Choose File" 

3. Pick the "INDY.DO" source file from your computer

4. Click in the big gray box; the cursor should be on BASIC. If not, use your keyboard to highlight BASIC and hit Enter

5. Type run"cas:indy" (including the quotes) and hit ENTER. The program should load and start

Leave a comment

Log in with itch.io to leave a comment.