Polymove

Type
Graphics
Category
Shape tweening (in-between animation) demo
Author
Robert Geddings
Published in
Antic, August 1987 (Vol. 6, No. 4)
Year
1987
Language
Atari BASIC
Requirements
32K RAM, Atari BASIC, joystick in port 1; GRAPHICS 15 option on XL/XE only

About the program

In traditional cartoon animation, many consecutive frames are almost identical, which leaves artists a great deal of repetitive work. Tweening is the computer's answer. The artist draws only the key frames, where something significant changes, and the computer works out the in-between ones. Robert Geddings of Eugene, Oregon, an Atari owner since 1984 who had only recently decided to see whether he could program anything at all, chose tweening as his first project. Polymove, in the August 1987 Antic, is the result.

You draw up to ten polygons of eight points each with the joystick. Polymove works out the steps between each shape and the next, and plays the morph once or in an endless loop. Geddings was clear about its limits. A real system would need hundreds or thousands of points and much finer output, and his in-betweens move each point in a straight line, whereas a raised arm, for example, sweeps through an arc.

What you need

An Atari 8-bit with 32K and Atari BASIC, plus a joystick. Geddings wrote it in OSS BASIC XE, where it runs quite fast. It works in plain Atari BASIC too, just more slowly; as he put it, don't expect real-time movies.

Typing it in

Only the title boxes use special characters: {CTRL-Q}, {CTRL-E}, {CTRL-Z}, {CTRL-C} are box corners and {CTRL-R} is the horizontal line (hold CTRL and press the letter). {inv}…{/inv} is inverse (Atari key), and {CLEAR}, {UP}, {LEFT}, {DEL LINE} and {BELL} are ESC followed by the key. The disk listing lacks the magazine's TYPO II codes.

How to use it

  1. RUN it, and enter how many polygons you want (up to 10) and a graphics mode: 3, 5, 7 or 8, plus 15 on an XL/XE.
  2. For each polygon, move the cursor with the stick and press the button to fix each of the eight points. A short beep confirms each point, and the outline is drawn as you go. Hold START to freeze and show the cursor's X,Y coordinates in a text window. A longer tone marks the end of each polygon.
  3. Choose 1 for a continuous loop (the last shape morphs back into the first; press the button to stop) or 2 for a single pass.
  4. Afterwards you can replay the same polygons, draw new ones or quit.

How it works

  • Linear interpolation. Lines 660–700 compute, for every point of every shape, a step of one fifth of the distance to the same point in the next shape: (X(LOOP,WORK)-X(LOOP,CNTR))/5. Playback (lines 100–210) draws the polygon, adds the steps to the working copy in TEMPX/TEMPY, clears the screen and repeats five times. Points are matched by number, so point 1 always morphs into point 1. The order you enter points in therefore decides whether a shape turns smoothly or twists through itself.
  • Detecting an XL/XE. Line 940 sets TRAP 1490 and tries GRAPHICS 15. On a 400/800 that mode doesn't exist, the error sends the program to line 1490 and XL is cleared, so the mode-15 option is offered only on machines that have it.
  • Full-screen modes. Line 1140 adds 16 to the mode to hide the text window. The START coordinate display then reopens the mode with a text window (GRAPHICS MODE+16, which comes to mode + 32) and afterwards without one (GRAPHICS MODE+32). Adding 32 tells the OS not to clear the screen, so your half-drawn outline survives both changes.

Variations to try

Geddings' own suggestion: delete the ? #6;"{CLEAR}" statements in lines 200 and 360. Each in-between frame then stays on the screen, leaving a trail that shows the whole morph at once. For smoother motion, change the 5s in lines 100, 300, 680 and 690 to a larger number of steps.

Listing

10 REM POLYMOVE
20 REM BY ROBERT GEDDINGS
30 REM (c) 1987, ANTIC PUBLISHING
40 GOTO 440
50 REM PLAYBACK
60 GRAPHICS MODE:POKE 710,0
70 ON SEL GOTO 90,290
80 REM CONTINOUS LOOP
90 CNTR=1
100 FOR COUNTER=1 TO 5:REM # OF TWEEN STEPS
110 IF STRIG(0)<>1 THEN 1300
120 PLOT TEMPX(1,CNTR),TEMPY(1,CNTR):REM STARTING POINT FOR EACH POLYGON
130 FOR LOOP=2 TO 8
140 DRAWTO TEMPX(LOOP,CNTR),TEMPY(LOOP,CNTR):REM FINISH POLYGON
150 NEXT LOOP
160 REM TWEEN PART
170 FOR LOOP=1 TO 8
180 TEMPX(LOOP,CNTR)=TEMPX(LOOP,CNTR)+STPSX(LOOP,CNTR):TEMPY(LOOP,CNTR)=TEMPY(LOOP,CNTR)+STPSY(LOOP,CNTR)
190 NEXT LOOP
200 ? #6;"{CLEAR}";
210 NEXT COUNTER
220 CNTR=CNTR+1:IF CNTR<=NUM THEN 100
230 FOR LOOP=1 TO NUM
240 FOR LOOP2=1 TO 8
250 TEMPX(LOOP2,LOOP)=X(LOOP2,LOOP)
260 TEMPY(LOOP2,LOOP)=Y(LOOP2,LOOP)
270 NEXT LOOP2:NEXT LOOP:GOTO 90
280 REM SINGLE LOOP
290 FOR CNTR=1 TO NUM-1
300 FOR COUNTER=1 TO 5
310 PLOT TEMPX(1,CNTR),TEMPY(1,CNTR)
320 FOR LOOP=2 TO 8:DRAWTO TEMPX(LOOP,CNTR),TEMPY(LOOP,CNTR):NEXT LOOP
330 FOR LOOP=1 TO 8
340 TEMPX(LOOP,CNTR)=TEMPX(LOOP,CNTR)+STPSX(LOOP,CNTR):TEMPY(LOOP,CNTR)=TEMPY(LOOP,CNTR)+STPSY(LOOP,CNTR)
350 NEXT LOOP
360 ? #6;"{CLEAR}";
370 NEXT COUNTER:NEXT CNTR
380 PLOT X(1,NUM),Y(1,NUM)
390 FOR LAST=2 TO 8
400 DRAWTO X(LAST,NUM),Y(LAST,NUM)
410 NEXT LAST
420 FOR DELAY=1 TO 500:NEXT DELAY
430 GOTO 1300
440 GOSUB 920
450 LOW=0:X1=INT(XTOP/2+0.5):Y1=INT(YTOP/2):C=1
460 FLAG=0
470 REM
480 FOR CNTR=1 TO NUM
490 GRAPHICS MODE:POKE 710,0:COLOR C
500 LOCATE X1,Y1,COLOUR:PLOT X1,Y1:XOLD=X1:YOLD=Y1
510 IF STRIG(0)<>1 THEN GOSUB 730
520 IF FLAG THEN 610
530 GOSUB 840
540 IF  NOT (TX OR TY) THEN 510
550 COLOR COLOUR:PLOT XOLD,YOLD:COLOR C
560 X1=X1+TX:IF X1>XTOP THEN X1=XTOP
570 IF X1<LOW THEN X1=LOW
580 Y1=Y1+TY:IF Y1>YTOP THEN Y1=YTOP
590 IF Y1<LOW THEN Y1=LOW
600 GOTO 500
610 X1=INT(XTOP/2+0.5):Y1=INT(YTOP/2):C=1
620 FLAG=0:COUNTER=0
630 FOR DONE=15 TO 0 STEP -0.15:SOUND 0,100,10,DONE:NEXT DONE:SOUND 0,0,0,0
640 NEXT CNTR
650 REM CALC STEPS
660 FOR CNTR=1 TO NUM:FOR LOOP=1 TO 8
670 WORK=CNTR+1:IF WORK>NUM THEN WORK=1
680 STPSX(LOOP,CNTR)=(X(LOOP,WORK)-X(LOOP,CNTR))/5
690 STPSY(LOOP,CNTR)=(Y(LOOP,WORK)-Y(LOOP,CNTR))/5
700 NEXT LOOP:NEXT CNTR
710 GOTO 1160
720 REM POINT ARRAY LOADER
730 FOR DELAY=15 TO 0 STEP -0.75:SOUND 0,60,10,DELAY:NEXT DELAY:SOUND 0,0,0,0
740 COUNTER=COUNTER+1
750 X(COUNTER,CNTR)=X1:Y(COUNTER,CNTR)=Y1
760 TEMPX(COUNTER,CNTR)=X1:TEMPY(COUNTER,CNTR)=Y1
770 PLOT X(1,CNTR),Y(1,CNTR):IF COUNTER=1 THEN 810
780 FOR TMP=2 TO COUNTER
790 DRAWTO X(TMP,CNTR),Y(TMP,CNTR)
800 NEXT TMP
810 IF COUNTER+1>8 THEN FLAG=1
820 RETURN
830 REM JOYSTICK ROUTINE
840 A=STICK(0)
850 TX=(A=5 OR A=6 OR A=7)-(A=9 OR A=10 OR A=11)
860 TY=(A=5 OR A=9 OR A=13)-(A=6 OR A=10 OR A=14)
870 IF PEEK(53279)<>6 THEN 900
880 GRAPHICS MODE+16:? "{CLEAR}X = ";XOLD,"Y = ";YOLD
890 FOR NN=0 TO 1:NN=(PEEK(53279)<>6):NEXT NN:GRAPHICS MODE+32
900 RETURN
910 REM INIT AND OPENING SCREEN
920 DIM X(8,10),Y(8,10),TEMPX(8,10),TEMPY(8,10),TM(8,2)
930 DIM STPSX(8,10),STPSY(8,10)
940 XL=1:TRAP 1490:GRAPHICS 15
950 GRAPHICS 0:POKE 752,1
960 POSITION 14,0:? "{CTRL-Q}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-E}"
970 POSITION 14,1:? "| {inv}POLYMOVE{/inv} |"
980 POSITION 14,2:? "{CTRL-Z}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-C}"
990 POSITION 11,4:? "by Robert Geddings"
1000 ? :? :? :?
1010 ? "Each Polygon that you create should":? "have 8 points, which you select with"
1020 ? "the joystick."
1030 ? :? "You can have up to 10 polygons."
1040 ? "How many do you want: ";:INPUT NUM
1050 POSITION 2,17:? "Graphics mode? (3/5/7/8";
1060 IF XL THEN ? "/15";
1070 ? ")  {LEFT}{LEFT}";:INPUT MODE
1080 IF  NOT (MODE=3 OR MODE=5 OR MODE=7 OR MODE=8 OR (XL=1 AND MODE=15)) THEN ? "{UP}{DEL LINE}{BELL}":GOTO 1050
1090 IF MODE=3 THEN XTOP=39:YTOP=23
1100 IF MODE=5 THEN XTOP=79:YTOP=47
1110 IF MODE=7 THEN XTOP=159:YTOP=95
1120 IF MODE=8 THEN XTOP=319:YTOP=191
1130 IF MODE=15 THEN XTOP=159:YTOP=191
1140 MODE=MODE+16:RETURN
1150 REM LOOP/SINGLE PLAYBACK
1160 GRAPHICS 0:POKE 752,1
1170 POSITION 16,3:? "{CTRL-Q}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-E}"
1180 POSITION 16,4:? "| {inv}SELECT{/inv} |"
1190 POSITION 16,5:? "{CTRL-Z}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-C}"
1200 ? :? :? :?
1210 ? "     1) CONTINOUS LOOP"
1220 ?
1230 ? "     2) SINGLE LOOP"
1240 ? :? :?
1250 ? "Enter Number of selection: ";:INPUT SEL
1260 IF SEL=1 THEN POSITION 7,22:? "{inv}PRESS BUTTON TO EXIT LOOP{/inv}"
1270 FOR DELAY=1 TO 400:NEXT DELAY
1280 GOTO 60
1290 REM AGAIN AND IF SO, HOW SO
1300 GRAPHICS 0:POKE 752,1
1310 POSITION 16,3:? "{CTRL-Q}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-E}"
1320 POSITION 16,4:? "| {inv}SELECT{/inv} |"
1330 POSITION 16,5:? "{CTRL-Z}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-C}"
1340 ? :? :? :?
1350 ? "     1) Do again, Same polygons":?
1360 ? "     2) Do again, Different polygons":?
1370 ? "     3) Quit"
1380 ? :? :? "Enter Number of selection: ";:INPUT SEL
1390 ON SEL GOTO 1410,1470,1480
1400 GOTO 1300
1410 FOR LOOP=1 TO NUM
1420 FOR LOOP2=1 TO 8
1430 TEMPX(LOOP2,LOOP)=X(LOOP2,LOOP):TEMPY(LOOP2,LOOP)=Y(LOOP2,LOOP)
1440 NEXT LOOP2
1450 NEXT LOOP
1460 GOTO 1160
1470 RUN
1480 POKE 752,0:END
1490 XL=0:TRAP 40000:GOTO 950

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: POLYMOVE.BAS.

Credits