Here - 1000 BiT

Here - 1000 BiT Here - 1000 BiT

11.07.2015 Views

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

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

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

Saved successfully!

Ooh no, something went wrong!