MAKING A GAME
By JACK CHUNG
By JACK CHUNG
Welcome to the world of programming. This series of articles will teach a BASIC programmer the basics of making a game. I have been programming for 4 years now on the ATARI and through trial and error, I have found a lot of special techniques. I will try to pass some of these techniques through the article also.
One of the phrases from a BASIC programmer I hear from alot of people is:
"I just learned BASIC but I don't know how to make objects move around the screen with a joystick."
One of the simplest techniques to move objects around the screen with BASIC is with the POSITION command. So to start out the program,we should first clear the screen.
10 GRAPHICS 0
When you clear the screen, the cursor will still be there. It doesn't look that good to have a cursor flying around the screen so we'll shut it off by:
20 POKE 752,1
The screen doesn't look that good in blue so the program should turn the color to black to look like space(hint!)
30 SETCOLOR 2,0,0
If your confused about some of the basic graphic commands this article is using, refer to the "BASIC REFERENCE MANUAL".
Now we start to get to the main part of the program:
40 S=STICK(0)
45 IF S=15 THEN 40
50 IF S=14 THEN Y=Y-1:REM MOVE OBJECT UP
60 IF S=7 THEN X=X+1:REM MOVE OBJECT RIGHT
70 IF S=13 THEN Y=Y+1:REM MOVE OBJECT DOWN
80 IF S=11 THEN X=X-1:REM MOVE OBJECT LEFT
After we put in the joystick checks, the program will print out the image by:
100 POSITION X,Y:? "*":REM BETWEEN THE QUOTES,YOU CAN PUT ANYTHING YOUR HEART DESIRES.
200 GOTO 40
Now type that program in and run it on the computer.
"But I don't want to have that funny trail everytime I move the joystick."
Ok,to make the object clear the trail, you add these lines:
41 DX=X:DY=Y:REM DUMMY LOCATIONS
90 POSITION DX,DY:? " ":REM THE " " CLEARS THE TRAIL
Now run the program. If the program still leaves the trail, you probably typed something in the program wrong.
If the object runs around the screen too fast for you, slow it down by adding this line:
120 FOR T=1 TO 50:NEXT T:REM FOR-NEXT LOOP
"That's great! But in my game, how would the program know if my object hit anything?"
Good question. To check for collisions,type in the following lines:
85 LOCATE X,Y,Z
86 IF Z<>32 THEN PRINT "BOOM":END:REM GET THE IDEA!
To see what Z is, check the ASCII code. Line 86 sees if the object hits anything. The 32 means blank space. So if Z<>32 means the object hit something other than blank space!
That'S all to make a object move around the screen. Isn't that easy. If you have any questions about anything in this article, write to me at ROM. Next issue, this article will explore further capabilities of the ATARI to make a game more exciting.