Programming Hints

Al Baker's Programming Hints: Apple and Atari

Al Baker

During games it is often easier to use a joystick than to play musical chairs trying to share the console between two or more people. The subroutine is from line 1000 up is useful in such applications.

Last Issue: Atari

I left the Atari readers with a problem last time: condense the number selection routine as much as possible and use it in a program. If you'd like to share your solution with the rest of us, send me a listing. My solution is in Listing 1. The program is the old favorite "Guessing Game."

The routine is condensed into lines 1000 to 1050. I made a few changes in it to accommodate the game. The main change was to remove the setup of the variable "A". The rest of the program is the standard number guessing program. Lines 7 through 23 initialize the variables, including "A", and lines 30 through 80 pick out a random number and ask the player to guess it.

Line 90 calls the joystick number selection routine. If the player makes a correct guess, then lines 200 to 220 tell him so and loop back for another game. Otherwise lines 117 to 140 give him a Bronx cheer, tell him how he was wrong, and loop back for another guess.

Program. Guess a Number

Download (Saved BASIC)
Download / View (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section