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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 13-ADVANCED MOVES 153So, when the pre-sh ift is XDRAWn over the rectangle, the dots on theleft side of both figures are on, so that whole row will be turned off. Butthe right side of the pre-shift is one row beyond the rectangle, and sinceonly the pre-shift dots are on, the result will be to turn that row of dots on.But enough words, l<strong>et</strong>'s try it! From BASIC type:XDRAW 2 AT 51,50XDRAW 2 AT 52,50XDRAW 2 AT 53 ,50XDRAW 2 AT 54,50XDRAW 2 AT 54,50XDRAW 2 AT 53,50The rectangle will move to the right, and then back to the left. If you aresurprised by the repeated XDRAWs at 54, remember that two consecutiveXDRAWs <strong>al</strong>ways cancel out. The fi rst XDRAW moves the rectangle right,and the second cancels it out to move the rectangle back to the left. Playwith XDRAWing this figure manu<strong>al</strong>ly until you can move it around comfortably.Listing 13-3 uses this idea to move the rectangle across the screen.10 REM PRE-SHIFT20 REM30 0$ = CHR$ (4)40 PRINT 0$ "BLOAD SQUARE"50 POKE 232,0 : POKE 233 ,360 HCOLOR = 3 : ROT = 0 : SCALE = 170 HGR80 DRAW 1 AT 20 ,10090 FOR I = 21 TO 275100 XDRAW 2 AT I ,100110 NEXT IListing 13-3.There are two very pleasant surprises with this program. The fi rst is that itis short and simple, and the second is that it moves the figure quickly andwith very little flicker!You might wish to compare this m<strong>et</strong>hod with the earlier one of XDRAWingthe shape on and off the screen. To do so, just make the followingchanges:80 FOR I = 20 TO 27590 XDRAW 2 AT I,100100 XDRAW 2 AT I,100Pre-shifting can be used for both horizont<strong>al</strong> and vertic<strong>al</strong> movement. Tod<strong>et</strong>ermine the pre-shift for any figure, just XDRAW it once, shift in the

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

Saved successfully!

Ooh no, something went wrong!