Classic Computer Magazine Archive COMPUTE! ISSUE 34 / MARCH 1983 / PAGE 70


L. L. Beh

"Closeout" has been tested by 30 people, aged 5 to 55, for over four months. Many claim that they enjoy this game even more than popular commercial games. Written originally for Atari computers with 16K of memory, it has been translated to also work on a VIC with any amount of memory.

This program just fits into a 16K Atari. Almost all lines contain multiple statements, so make no alterations unless you have a bigger machine.

Scrambling For Bargains

Here's how you play the Atari version (VIC-20 owners should refer to the "VIC Notes"):

There's a huge sale going on at a local department store. You arrive at the multi-story building hungry for bargains. Boldly, you enter the store and look around – and see bargains galore. A real sale! You start gathering up sale items, but then become aware of a strange group of shoppers. Wherever you go, they follow you around. Soon you learn their true intentions – they are out to stop you at all costs, so they can have the store to themselves. What's worse, they're armed with ray guns from the Toy Department and modified to work!

The object of "Closeout" is to snatch up as many sale items as possible while evading the hostile bargain hunters. Don't let them get too close, because they'll either capture you or shoot you. Some of them can shoot farther than others. You can shoot back with the slingshot you bought in the Sporting Goods Department (50 percent off), but since slingshots require two hands to shoot, you must drop 25 sale items each time you use it.

You have only one chance and about three minutes of play. Extra time is awarded for higher scores. The remaining time is indicated on the left, and colors change as time runs out (there can be up to nine different colors on the screen at a time). When your score surpasses 25 points, you can shoot your slingshot, but remember, it costs you 25 points. You can only shoot horizontally, by aiming the joystick and pressing the fire button. The best strategy is to shoot only when cornered.

After you have typed in the program, save it twice on disk or tape, then type RUN. There will be a short initialization pause, and the screen will clear to GRAPHICS 7. The four players will appear, and the floors and stairways will be drawn. Short instructions will appear. Plug your joystick into port one. Press the fire button to start.

Your shopper is on the ground floor in the bottom left corner. Use the joystick to move left and right, or up and down stairs. You must be directly under the stairs to use them, and to exit onto a floor you must be standing exactly on it.

The program might run faster on U.S. Ataris than on my New Zealand model. The game for Atari is based on an idea in "P/M Graphics Made Easy" (COMPUTE!, February 1982) which animates the players with vertical blank interrupts (the split-second interval between the display of video frames). American televisions use the NTSC standard, which allows 60 vertical blank interrupts per second, while New Zealand's PAL standard allows only 50. On the other hand, the 6502 Central Processing Unit chip in our Ataris is clocked at three megahertz, as opposed to 1.8 MHz in U.S. Ataris, so the two factors might cancel each other out.

Good luck! I'd like to know who can better my score of 1200 points.

Since I omitted REM statements from the program to save space, here is a short explanation of the Atari version:

Line No. Comments
10 Initializes. Jumps to line 209 to POKE in the P/M utility and player shapes, then to line 112 to wait for the trigger to be pressed to start the game. These jumps keep the lower numbered lines free for frequently accessed statements.
20-23 Check for your moves up the stairs.
30-33 Check for your moves down the stairs.
37-44 Check for enemy movement on the left stairs.
55-59 Check for enemy movement on the right stairs and also give the enemy some brainpower.
60-65 Check for enemy movement on the middle stairs.
73-76 Reading of joystick one (second slot from left) to determine your moves. Change this reading here and at two other locations if you want to use any other slot for the game.
78 Uses BASIC LOCATE statement to determine points scored.
79 If the sale items run low, draw some more.
80-82 Determine movement of Player 2 – Enemy No. 1.
84-86 Determine movement of Player 3 – Enemy No. 2.
87-89 Determine movement of Player 4 – Enemy No. 3.
90 Checks if you can shoot.
93-95 Check to see if you are in the enemy shooting range. Note: some enemies can shoot farther than others.
96 Game timekeeper.
97 Go back to start of loop.
100-101 Draw dots – sale items.
105-108 Draw time bar graph and erase the portion of time that has run out; also award extra time for high scores.
109-114 You got shot! So these lines get you off the visible side of the screen, and you wait for the trigger to be pressed to start a new game.
209 Only simple constants and variables are used in the program. These constants and variables are used all over the place to conserve RAM; they are also used for the line numbers. These make the program look very untidy, but this is the only way I can get this program to run on my 16K Atari.
210-215 POKE the P/M utility and players' shapes and colors into RAM.
216-225 Constants and variables for the stairs and building levels; draw it out in Graphics 7.
230 Data for P/M graphics utility as presented in COMPUTE! (February 1982).
236-237 Last eight DATAs in line 236 and all of line 237 are for the P/M shapes. Change these if you like different shapes.

Snatching up sale items on the bottom floor while evading enemy shoppers in the Atari version of "Closeout."

Enemy shoppers have captured the player in this game of "Closeout," VIC-20 version.

VIC-20 Notes

Charles Brannon, Editorial Assistant

The VIC-20 version of Closeout, like the Atari version, uses almost all the memory that the unexpanded 5K VIC can offer. Don't enter any extra spaces or semicolons. It will run on any size VIC. "Floating" memory is handled in lines 180 and 190. Instead of using TX = 7680, the start of text memory on a 5K VIC, the formula in line 180 will return the proper address for any VIC. For more information on POKEing the screen, see "The Window" (Home and Educational Computing!, Fall 1981, or COMPUTE!'s First Book Of VIC).

Playing VIC-20 Closeout

Using the I,J,K,M keys (I = up, M = down, J = left, K = right) move yourself (represented by the "pi" symbol) around the department store, avoiding the rapacious bargain hunters who mercilessly pursue you. Pick up the various sale items by moving your character over the colored dots. You can ascend and descend escalators to move from floor to floor. If a fellow shopper gets too aggressive, you can deliver a shove that will send him reeling back to the top floor. You start out with three shoves, and you get two more every time you acquire 120 sale items (at which point you move on to a whole new store). Press SPACE to deliver a shove, but be careful not to run out of them. You cannot use your shoves while you're on an escalator. Unlike the Atari version, you have no time limit to worry about.

Special Techniques

In an attempt to get the most speed from a BASIC program while using the least amount of memory, there are several tricks here that may be useful to VIC programmers. First, variables replace much-used constants. For example, the number 22 (number of characters per line) is used extensively in the screen POKE statements. Initially setting Q = 22 at the start of the program lets me substitute Q for the constant 22. Aside from the convenience of this, using variables is much faster. Instead of converting the characters "22" to the floating point equivalent, the computer only has to look up the value of Q. It seems trivial, but judicious use of variables can significantly speed up your programs. Also note that the letter "O" is used instead of zero in some places for the same reason.

Artificial Intelligence?

A game like this is the perfect opportunity to fiddle with artificial intelligence. When you write a routine that makes a character chase another, you've simulated a simple animal's "instincts," or predetermined behavior.

The crazed shoppers in Closeout must know how to home in on you. Their behavior must include the ability to get on and off the escalators. One thing you should watch out for when writing games like this is predictability. If your "intelligence" subroutine is too good, your creatures will accurately home in on the victim, but they will act in predictable ways. Sometimes it helps to stir a little randomness in with the RND function (we humans call such "careful" randomness creativity).

Since all three pursuers use the same "intelligence" algorithm, we've just created "mini-arrays" that hold important variables for each character: the X and Y position, the character used, the current direction, and the character "underneath" the pursuer. To move a character non-destructively, you have to save and restore the background characters. The routine can move any of the three chasers according to E, the "Enemy index." To create the illusion of simultaneous motion without slowing down the player too much, only one chaser can move for every move the player makes.


If you have more than the normal 5K RAM memory in your VIC, you might want to make some enhancements to the game. You could add: custom characters, improved sound effects, and more pursuers.