|Dͻ
|D |5The Happy Hacker |D
|Dͼ

^C^1Bits 'N PC's
^Cby
^CGeorge Leritte

   This month we will discuss some graphic animation techniques.  Creating 
animated graphics breaks down into three areas - choosing what and how to 
animate, creating the graphics, and animating them. 

   You must first have a pretty good idea about what you want to animate before 
starting.  The programming language you use also affects your decisions.  Do you 
want to move the images on a blank screen or across a background?  Will you want 
to test for collisions? 

   BASIC is my preferred instrument for novice animators, at least until one has 
gotten a little experience moving the pictures or whatever around the screen.  
GWBasic and QuickBasic have several built-in commands just for animation.  We 
will use Basic's instruction set for demonstration purposes. 

   BASIC has the following drawing commands available:  PSET, PRESET, LINE, 
CIRCLE, and PAINT.  PSET and PRESET are used to put points on the screen.  LINE 
is used to draw lines, boxes, and filled boxes.  CIRCLE is used to draw circles, 
ellipses, and arcs.  These commands work on absolute or relative coordinates.  
PAINT is used to fill an area on the screen with a color or a pattern.  To 
animate with them is difficult, but not impossible.  Continually drawing the 
same series of lines and points to animate each position is slow and clumsy. 

   BASIC provides a way to move a block of pixels around the screen - GET and 
PUT.  With GET, you can place a screen image into a variable array.  PUT 
reverses this option, but you can put the image into another spot on the screen.  
To animate simple pictures, you could draw them once, use GET to store the 
image, and then use PUT to animate the image across the screen.  BASIC has five 
ways to PUT the image on the screen:  PSET, PRESET, AND, OR, and XOR.  PSET 
overwrites what is on the screen with the image in the array.  PRESET overwrites 
with the reverse of the image in the array.  AND transfers the image if one 
exists on the screen.  OR superimposes the image on an existing image.  The one 
most useful for animation is XOR.  You could PUT an image on the screen and then 
erase it with another PUT, update where you want to place it, and PUT it in its 
new position all while preserving the background.  An alternative, if you don't 
care about the background, is to place a clear border around the image, and then 
successively place it in its new position with the PSET option, erasing the old 
image at the same time. 

   Once you've decided what to animate, and how to animate it, the images must 
be created.  You can use a commercial drawing program if you can get the image 
into your program once you've created it.  Since ARTIST is written in BASIC, you 
could use it to create your images, and save the picture to disk.  You could 
BLOAD the picture into a program and GET the portions you need, and save them as 
data statements, a data file, or as a BLOADable file. 

   When using GET and PUT, the image could be stored in data statements and read 
into the array at the beginning of the program, or it could be saved to disk 
with BSAVE and BLOADed at the beginning of the program.

   All of the above techniques will work with any language that offers graphic 
command statements.
