Here - 1000 BiT
Here - 1000 BiT Here - 1000 BiT
INSTRUCTOR NOTES 31 SPRITES ^The VIC chip in the Commodore 64 controls the video displays. In particular, it controls ^jeight sprites, powerful bit-mapped graphics objects (24 bits wide and 21 bits high).This lesson gives the student a program in which the sprite she draws on the screen isPOKEd into memory without the drudgery of determining bit patterns and changing ^them to decimal numbers.The sprite can be colored with one POKE and moved to another spot on the screen with ^jone to three more POKEs. Each sprite is told which picture to display by a "pointer"updated with a single POKE. Many pictures can be stored ahead of time and rapidly Odisplayed one after another by the same sprite. Conversely, several sprites can displaythe same picture in different colors and different spots on the screen at the same time. ^Those portions of a sprite in which the bit is "0" are transparent, showing whateverobjects (other sprites or screen graphics) are behind them. The frontmost sprite of an \^joverlapping pair is the one with the lowest sprite number. For each sprite, the programmercan choose whether it passes in front of or behind objects in the static screen display. ^JEach sprite can be expanded to double size in the horizontal or vertical (or both) ^dimensions. Multicolored sprites can be made (three colors plus background) but this is >,not explained in this book.There are two registers for recording collisions involving sprites. One records if a spritehas collided with any background drawing on the screen. The other records which sprites ^Jhave collided with other sprites. These registers keep a record of the collision, even if thesprites have moved off and are no longer overlapping, until the register is read with a ^PEEK. Then the register is cleared to zero, "no collisions." ^.QUESTIONS:1. How do you tell sprite 0 which picture to show?2. How do you tell sprite 0 to move to the center of the screen? * ^j3. How do you color sprite 1 red? ^J4. How do you tell sprite 2 to grow wider? ^5. What does the "sprite hits sprite?" register contain if sprite 3 and sprite 5are overlapping?^jo176
LESSON 31SPRITES FOR ACTION GRAPHICSThe VIC chip in the computer controls eight sprites.A sprite is a little picture which moves on the screen. You draw the picture and put itinto memory beforehand. Sprites let you put powerful moving graphics into yourprograms.SPRITE ZERO, OBEY OUR WISHES!10REM SPRITE-—5PRINT"clrblk":REM BLACK LETTERS16 POKE 53281,1:REM WHITE SCREEN20 REM —-22 V=53248SET UP VIC:REMVIC BASE ADDRESS23 REMPICTURE24 B=200:REM BLOCK NUMBER26 POKE 2040.B:REM PUT IN BLOCK 20028 GOSUB 200:REM STORE PICTURE30 REMENABLE SPRITE 032POKEV+21.1:REM TURN ON SPRITE 034POKEV+39.0:REM BLACK COLOR40 REM -USE TO SPRITE42 FOR P=1 TO 20044 POKE V+0.P45 POKEV+1.P49 NEXTP50 FOR l=7 TO 0 STEP -155POKEV+39.I:REM:REM:REMX POSITIONY POSITIONALL COLORS60 FOR T=1 TO 1000:NEXT T65 NEXT I70POKEV+29.1:REMFAT SPRITE71 GOSUB 10072POKEV+23.173 GOSUB 10074POKEV+29.075 GOSUB 10076POKEV+23.0:REM:REM:REMFAT AND TALLTALL ONLYSMALL AGAIN77 GOSUB 10090 POKE V+21.0:REM TURN SPRITE OFF96 LIST 300100FORT=1 TO 1000: NEXTT: RETURN200 REM — STORE SPRITE --201 L=0:PRINT" PLEASE WAIT"202 FOR l=0 TO 20:READ R$177
- Page 125 and 126: INSTRUCTOR NOTES 22POKEing GRAPHICS
- Page 127 and 128: Try this: Change the number 83 to a
- Page 129 and 130: We can number the streets and house
- Page 131 and 132: n INSTRUCTOR NOTES 23 SECRET WRITIN
- Page 133 and 134: THE COMPUTER ISIMPATIENTThe compute
- Page 135 and 136: ^ INSTRUCTOR NOTES 24 PRETTY PROGRA
- Page 137 and 138: Assignment 24A:1. The delay loop is
- Page 139 and 140: Assignment 24B:1. Write a short pro
- Page 141 and 142: LESSON 25 LOGIC: AND, OR, NOTANOTHE
- Page 143 and 144: THE IF COMMAND TELLS LITTLE WHITE L
- Page 145 and 146: THE LOGIC SIGNSYou can use these si
- Page 147 and 148: LESSON 26 SNIPPING STRINGS: LEFTS,
- Page 149 and 150: CUTTING A PIECE OUT OF THE MIDDLETh
- Page 151 and 152: nnO INSTRUCTOR NOTES 27 SWITCHING N
- Page 153 and 154: MAKING NUMBERS INTO STRINGSRun10 RE
- Page 155 and 156: Assignment 27:1. Write a program wh
- Page 157 and 158: LESSON 28ACTION GAMES AND THE FUNCT
- Page 159 and 160: LOOKING IN THE KEYBOARD'S BOXHere i
- Page 161 and 162: Run it. It puts a white diamond on
- Page 163 and 164: cTHETARGETS ARE HEARTSAdd these lin
- Page 165 and 166: LESSON 29MUSICGo back and review th
- Page 167 and 168: REGISTER ADDRESSES Base address is
- Page 169 and 170: D^ INSTRUCTOR NOTES 30 ARRAYS AND T
- Page 171 and 172: The DIM... command tells the comput
- Page 173 and 174: 1 REM *** EIGHT QUEENS ***2 GOTO 10
- Page 175: Assignment 30:1. Write a program wh
- Page 179 and 180: Then use the CRSR keys to move the
- Page 181 and 182: MANY SPRITES AT ONCEHere are the bo
- Page 183 and 184: WATCH OUT, TWO SPRITES ARE GOING TO
- Page 185 and 186: LESSON 32USER FRIENDLY PROGRAMSTher
- Page 187 and 188: TIE A STRING AROUND THE USER'S FING
- Page 189 and 190: SET TRAPS FOR ERRORSExample: Add th
- Page 191 and 192: LESSON 33DEBUGGING, STOP, CONTTHE S
- Page 193 and 194: Use the PRINT command to look at va
- Page 195 and 196: RESERVED WORDSABSAND ASC ATNCHR$CLR
- Page 197 and 198: ells and whistlesA phrase going bac
- Page 199 and 200: error trapPart of a program which c
- Page 201 and 202: listingA list of all the lines in a
- Page 203 and 204: emarkA comment you make in the prog
- Page 205 and 206: variableA name given to a box in me
- Page 207 and 208: FORMULA TOO COMPLEXYou wrote a stri
- Page 209 and 210: SYNTAXYou "spelled" the line wrong.
- Page 211 and 212: 1 REM A4-310 REM*** SMILE***13 POKE
- Page 213 and 214: 1 REM A6-210 REM*** FAVORITE***15 P
- Page 215 and 216: ~ 40 INPUT C$1 REM A9B-210 REM ***
- Page 217 and 218: ^ 1 REM A11A-210 REM !"#$% INSULTS
- Page 219 and 220: 1 REM A12B-410 REM *** PICK A CARD
- Page 221 and 222: ^ 1 REM A15-210 REM!!! VACATION!!!r
- Page 223 and 224: ■1 REMA17B-510 REM*** OPERA SOPRA
- Page 225 and 226: 1 REM A22-110 REM *** COLORED BOX *
LESSON 31SPRITES FOR ACTION GRAPHICSThe VIC chip in the computer controls eight sprites.A sprite is a little picture which moves on the screen. You draw the picture and put itinto memory beforehand. Sprites let you put powerful moving graphics into yourprograms.SPRITE ZERO, OBEY OUR WISHES!10REM SPRITE-—5PRINT"clrblk":REM BLACK LETTERS16 POKE 53281,1:REM WHITE SCREEN20 REM —-22 V=53248SET UP VIC:REMVIC BASE ADDRESS23 REMPICTURE24 B=200:REM BLOCK NUMBER26 POKE 2040.B:REM PUT IN BLOCK 20028 GOSUB 200:REM STORE PICTURE30 REMENABLE SPRITE 032POKEV+21.1:REM TURN ON SPRITE 034POKEV+39.0:REM BLACK COLOR40 REM -USE TO SPRITE42 FOR P=1 TO 20044 POKE V+0.P45 POKEV+1.P49 NEXTP50 FOR l=7 TO 0 STEP -155POKEV+39.I:REM:REM:REMX POSITIONY POSITIONALL COLORS60 FOR T=1 TO <strong>1000</strong>:NEXT T65 NEXT I70POKEV+29.1:REMFAT SPRITE71 GOSUB 10072POKEV+23.173 GOSUB 10074POKEV+29.075 GOSUB 10076POKEV+23.0:REM:REM:REMFAT AND TALLTALL ONLYSMALL AGAIN77 GOSUB 10090 POKE V+21.0:REM TURN SPRITE OFF96 LIST 300100FORT=1 TO <strong>1000</strong>: NEXTT: RETURN200 REM — STORE SPRITE --201 L=0:PRINT" PLEASE WAIT"202 FOR l=0 TO 20:READ R$177