Classic Computer Magazine Archive ANTIC VOL. 4, NO. 3 / JULY 1985

game of the month


Plus golf course "construction set"


Play 8 holes of Atari miniature golf on your Atari and then design your own golf course. Two BASIC programs (Golf and Construction Set) run on all Atari computers with 24K cassette or 32K disk. Disk or cassette. You'll also need your trusty joystick as a golf club.

When you get tired of dodging demented robots, skulking around caves and frying alien creatures, try your aim at miniature golf, a surprisingly holesome (ouch) game for the entire family.
   There's no real limit to the number of players-you could even take this game to a party along with last month's "Beer Party Atari!" The computer will keep track of each golfer's scores and turns to play.
   But first, type in Listing 1, check it with TYPO II and SAVE a copy before you RUN it.
   Swing your club by moving the joystick. The club appears as a square with a missing corner. Pushing the joystick button starts your shot. The farther the distance between the club and the ball, the harder the ball will be hit. This means you can try some interesting bounce shots.
   The important part of the club is the missing corner. The velocity is calculated from the distance between this corner and the ball; the direction the ball travels is also calculated from the corner.
   Holes-in-one are possible on all the holes provided.
   When you sink the ball, play moves to the next player, until all players have played all the holes. The game is then over, and a screen display shows everyone's score plus the name of the winner.
   To add additional realism to the course, there is a moving barrier, reminiscent of the windmills found on real miniature golf courses!
   Sometimes you totally miss the ball. If your opponents are kind-hearted souls, all you need to do is press the START button-and you can take the shot over again. These extra shots don't even show up on your score.

Eventually you'll want to design your own holes. That's when you can use the Miniature Golf Construction Set (CS), which generates data statements that are appended to the MG program in line 2000. To use CS, type in Listing 2, check it with TYPO II, and SAVE a copy.
   Start with graph paper. It's best to design your hole before going to the computer. You're designing a screen for Graphic Mode 7, so you'll need a grid spanning 0-159 horizontal (x coordinate) and 0-79 vertical (y coordinate).
   In constructing a hole, you choose from seven types of prefabricated obstacles (see Figure 1). These include four types of right triangles-right, left, up and down, named according to the direction that the apex points. The fifth obstacle is a rectangle, the sixth is a diagonal line, and the seventh a moving barrier. In each case, you determine where to put the obstacle and how big it should be.
   When you first run CS, it will ask you where you want your output. Either give D:FILENAME (or C: for cassette). The screen will also request the hole number.
   You'll then be asked where you want the hole placed, first with the x position coordinate and then the y coordinate. The program will always specify the information and format it wants.
   After locating the hole, specify the starting position for the ball, again by entering the x and then the y coordinates.
   With these starters completed, you can place the obstacles. The CS program will run through a sequence, offering you a chance to include down triangles, up triangles, squares, and so on. In each case, you are asked how many obstacles (0-15 of each), and are then led through the process of locating each one.

Let's create a sample hole. When asked for a hole number, type [1] [RETURN]. Look at Figure 2 for a sample design. Let's say you want your field to have five objects: a down triangle, an up triangle, a rectangle, a diagonal barrier and a moving obstacle.
   Start by placing the hole. The CS program will prompt you to enter x, then y. Type [20] [RETURN] [20] [RETURN]. Place the ball at, say, 150,60 by typing [150] [RETURN] [60] [RETURN].
   You'll now be asked how many down triangles you want. Enter [1] and a [RETURN]. Specify the position by locating the baseline-because it's a right triangle, the computer will do the rest. Enter the coordinates in the format requested, with a comma between each number and a [RETURN] at the end of the entry. Thus, a small down triangle in the upper right corner of the field would be 141,0,159.
   Establishing an up triangle works the same way. Choose [1] up triangle, then enter 40,79,141 [RETURN] to get the large triangle in Figure 2.
   If you don't want a certain obstacle, enter [0] when asked "How many?". For this sample, we don't want any right or left triangles.
   Choose [1] square/rectangle then specify the square's location by naming the two corners: 70,0,120,20.
   The barrier starts with a yes/no choice. Choose [1], and then establish the length of the line along which the barrier moves, as well as the speed it moves. Higher numbers are faster. Use 5,40,60 for the placement and 3 for the speed.
   The diagonal lines are located by specifying a corner's x and y coordinates, followed by the lower x position. Try 5,50,26.
   When you're finished making a fiendishly difficult hole, you'll be presented with the main menu, which has four choices. The first thing you'll want to do is look at the hole you've just constructed.
   If the program encounters any errors attempting to draw the screen, it will stop and let you look at the screen to try to figure out what went wrong. The most common error is to place a triangle too close to the screen edge, so that when the computer attempts to draw the missing corner, you get a cursor out of range.
   Touching any key returns you to the main menu, where you may wish to use the second selection, Edit. This takes you to a submenu with a list of obstacles to edit. You must re-enter ALL the data for the particular obstacle you are editing. To return to the main menu, choose option 9 from the submenu.
   The third choice lets you Save your data. The final choice is to Quit. If you make this choice by accident, however, all is not lost. Just type GOTO 240 and press [RETURN].

Now that you've gone through all this work to generate the data, how do you use it? First, LOAD or CLOAD Miniature Golf into your computer. Then ENTER "D:FILENAME" or ENTER "C:" the data created using MGCS. For example, if you used D:ROUND for the filename to save your data when using CS, then you would ENTER "D:ROUND". If you are adding more holes, then you will need to adjust the variable MAXHOLE in line 10 of Miniature Golf.
   Then SAVE the version with the new hole data, and RUN it. Be warned that if you chose to create a hole number using CS that already exists in your current version of Miniature Golf, your new hole will replace the old one. This change becomes rather permanent if you then write the new version with the same filename as the old one back to the same disk.

Miniature Golf figure 1

Miniature Golf figure 2


Fl-flag so that you can't keep pressing the START button and back up your score.

STARTHOLE, MAXHOLE-the hole to start on and the final hole.

PN, NUMPLAY-the current player number, and the total number of players.

HOLSCR-the current hole score.

HOLENUM-the current hole number.

TOTAL-array which holds each player's score.

OLDX, OLDY-the ball's x and y coordinates before your last shot.

BALLX, BALLY-ball's x and y coordinates.

MX, MY-ball's x and y velocities.

HX, HY, HSX, HSY-the magnitude and sign of the ball's x and y velocities.

BX, BY-moving barrier's x and y coordinates.

RITEX, LEFTX, SPEED-the moving barrier's limits of back-and-forth motion, and the speed of movement.

CLUBX, CLUBY-x and y coordinates of the club.

CLUB$, BARRIER$, HOLE, BALL$, BLANK$-arrays to hold the shape data of appropriate items.

UD1$, UD2$, UD3$-arrays which hold the data for the machine language routines to move the players (ball, club, barrier).

NAME$-array to hold the names of each player.


5-15 Set up and call the subroutines to get information.

20-50 Main Loop. For each hole (line 20), it updates the text window and draws the hole (line 30). Each player moves the club and shoots (line 40). Then erases the hole (line 50).

60 Jump to Game Over routine.

700-790 Moves the ball around the field. If a collision is detected with the playfield or the moving barrier then velocities are adjusted. If the ball goes in the hole, calls the subroutine at 850. Note that lines 775-776 do exactly the same thing as the subroutine at line 800 (move the moving barrier), but at a 25% increase in speed, because you don't have to call a subroutine.

850-880 Sound and graphics for the ball going into the hole.

900-990 Moves the club when you move your joystick. It reads the joystick (lines 910-920), checks the status of the START button and the flag (line 925), adjusts and redraws the ball and club if the [START] button is pushed the first time, and erases and redraws the club (930). If the button is pushed, lines 940-960 calculate the x and y distances between the club and ball, and "swing" the club. Note that if the club and the ball have the same coordinates, you get a nasty beep.

1000-1090 Read the data that defines each hole and draws the hole, including the club and ball.

1100-1130 Draws a type one or two obstacle.

1200-1230 Draws a type three or four obstacle.

1300-1330 Draws a type five obstacle.

1400-1420 Draws a type six obstacle.

1430-1440 Draws a type seven obstacle.

1450-1490 Erases the P/M shapes by writing zeros from BLANK$ into their positions.

1500-1550 Gets the names of the players. This routine has you input the names into a temporary string, then pads any unused spaces (up to 10) with blanks so that each name is the same length. That way, we can find the name in the larger string NAME$.

1600-1735 Sets up the graphics, memory and P/M space and enables P/M graphics. It also reads the shape data into the arrays, and reads the machine language routine data into their arrays.

1750-1770 Updates the text window.

2000-2141 Data for the holes.

3000-3050 The introductory screen.

3100-3320 The Game Over sequence.

David Plotkin, a regular contributor to Antic, has recently been noted for his ACTION! games in these pages. He is a chemical engineer by profession.

Listing 1  MINIGOLF.BAS Download

Listing 2  MGCONST.BAS Download

On disk  MGEXT2.DAT Download