In this example for Atari Basic Animation, you will learn how to setup a simple graphics pixel on the screen and watch it move around the edges of the screen in Graphics mode 3.
The code is displayed in a step by step sequence for easier reference and learning.
Graphics Mode 3
In the first part of our program we will set the mode to GRAPHICS 3 and turn on COLOR 1, which comes out as an orange color. Be sure to check out the Atari Graphics 3 page to learn even more!
In line 30 we are using a command a REM, which stands for “remark”. It essentially is just a comment. Comments don’t execute any actions with our Atari Basic Animation program, but help guide the programmer with what a particular line is doing.
A Basic Loop Example
The next part of our Atari Basic program sets up our very first a loop. A loop continues to repeat a set of instructions until it ends. In this example, X will look through 38 times.
The next part of our Basic program sets up our very first a loop. A loop continues to repeat a set of instructions until it ends. In this example, X will look through 38 times.
A Subroutine Call
The PLOT X, Y will track the range of the X variable, and Y will stay consistent (at a default of zero, for now). Finally the NEXT X will continue the loop until it has counted from 0 to 38, which causes the dot to move across the screen from left to right.
Once again we have a loop here. The variable D will count from 1 to 50 and then end, with nothing else going on. This acts as a “delay” to slow down the animation state. Then we turn off the pixel moving on the screen, and return back where we left off at.
Atari Basic Animation begins
We have now entered a new loop. The X loop has ended, but we are now start a Y loop. This Atari Basic Animation loop is counting from 0 to 18, plotting the pixel moving along the way down the right edge of the screen, and setting the delay to slow it down, like we learned about in the first example.
Moving from right to left
Once we are at the bottom right corner, we will begin to move to the left. In this example, we count backward from 39 to 0. The “STEP -1” will allow the loop to reverse. Then we plot our pixel (dot) and begin the Atari Basic Animation once again.
Returning to the upper left edge
We have arrived at the last few lines of our loop. This time the pixel is setting at the far left, bottom edge of the screen. Then we count our Y loop backward from 18 to 0 until our dot has arrived back at the very first position on the screen at 0, 0. We are done as the “END” tells us and exists back to Atari Basic.