12.07.2015 Views

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

138 APPLE II COMPUTER GRAPHICScaused by the need to initi<strong>al</strong>ize a number of variables and arrays beforebeginning the animation. In Listing 12-1, line 4(/) s<strong>et</strong>s the seven Y coordinatesused in the figure, and line 16(/) assigns the corresponding memoryaddress to each of those coordinates. Lines 8(/) through 11(/) initi<strong>al</strong>ize anarray that contains seven data v<strong>al</strong>ues for each of the four versions of thepropeller.The actu<strong>al</strong> animating is done in lines 21(/) through 25(/) which POKE thev<strong>al</strong>ues for each frame into Hi-Res memory. The variables and arrays usedin the POKEs tend to obscure some of the mechanics of the program, bu'tthey <strong>al</strong>so enhance the execution, since it is much faster for the machine tolook up the v<strong>al</strong>ue of Y%(4) stored in memory than to generate the correspondingv<strong>al</strong>ue of 12288.In gener<strong>al</strong> it is faster to look som<strong>et</strong>hing up in a table than to generate iteach time it is needed...Line 22(/) POKEs the first and seventh bytes of the figure [V%(1, 1) andV%(1,7)], 23(/) the second and sixth, and 24(/) the third, fifth, and fourthbytes. POKEing the v<strong>al</strong>ues in that weird order improves the resulting effect,but you might try changing the order to POKE them sequenti<strong>al</strong>ly just to seewhat happens.Another reason fo r the variables is to make it easy to mod ify this programso that the figure will plot at different Y coordinates on the screen.The array Y% will contain the starting addresses for each of the 192 screenlines, and Yl % through Y7% will be the coordinates for the seven linesused in the shape.The propeller is an example of stationary animation. That is, animationthat takes place within a fixed region, and the different frames of thatregion are <strong>al</strong>ternated to simulate movement. There are many applicationsfor stationary animation. The APPLEVISION program on your DOS 3.3master is an excellent example, and so is a Hi-Res scoreboard for a game.(The ten diffe rent digits compose ten possible frames for display.)Drop the PropMost shapes used in a game are required to move about the screen. Wewill now <strong>al</strong>ter our program to <strong>al</strong>low for this. With Listing 12-1 still inmemory, type in the fo llowing changes.16 GOSUB 1 : REM CALC ADDRESSES245 Y1% Y1% + 1: Y2% Y2% + 1:Y3% Y3% + 1: Y4% Y4% + 1:Y5% Y5% + 1: Y6% Y6% + 1:Y7% Y7% + 1246 IF Y7% > 192 THEN END1 REM

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!