[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

 10 REM SPRITE EXAMPLE 3...
 20 REM THE HOT AIR GORF
 30 VIC=53248:REM THIS IS WHERE THE VIC REGISTERS BEGIN
 35 POKEVIC+21,1:REM ENABLE SPRITE 0
 36 POKEVIC+33,14:REM SET BACKGROUND COLOR TO LIGHT BLUE
 37 POKEVIC+23,1:REM EXPAND SPRITE 0 IN Y
 38 POKEVIC+29,1:REM EXPAND SPRITE 0 IN X
 40 POKE2040,192:REM SET SPRITE 0'S POINTER
 50 POKEVIC+28,1:REM TURN ON MULTICOLOR
 60 POKEVIC+37,7:REM SET MULTICOLOR 0
 70 POKEVIC+38,4:REM SET MULTICOLOR 1
 180 POKEVIC+0,100:REM SET SPRITE 0'S X POSITION
 190 POKEVIC+1,100:REM SET SPRITE 0'S Y POSITION
 220 POKEVIC+39,2:REM SET SPRITE 0'S COLOR
 290 FORY=0TO63:REM BYTE COUNTER WITH SPRITE LOOP
 300 READA:REM READ IN A BYTE
 310 POKE12288+Y,A:REM STORE THE DATA IN SPRITE AREA
 320 NEXT Y:REM CLOSE LOOP
 330 DX=1:DY=1
 340 X=PEEK(VIC):REM LOOK AT SPRITE 0'S X POSITION
 350 Y=PEEK(VIC+1):REM LOOK AT SPRITE 0'S Y POSITION
 360 IFY=50ORY=208THEN DY=-DY:REM IF Y IS ON THE EDGE OF THE...
 370 REM SCREEN, THEN REVERSE DELTA Y
 380 IFX=24AND(PEEK(VIC+16)AND1)=0THENDX=-DX:REM IF SPRITE IS...
 390 REM TOUCHING THE LEFT EDGE, THEN REVERSE IT
 400 IFX=40AND(PEEK(VIC+16)AND1)=1THENDX=-DX:REM IF SPRITE IS...
 410 REM TOUCHING THE RIGHT EDGE, THEN REVERSE IT
 420 IFX=255ANDDX=1THENX=-1:SIDE=1
 430 REM SWITCH TO OTHER SIDE OF THE SCREEN
 440 IFX=0ANDDX=-1THENX=256:SIDE=0
 450 REM SWITCH TO OTHER SIDE OF THE SCREEN
 460 X=X+DX:REM ADD DELTA X TO X
 470 X=XAND255:REM MAKE SURE THAT X IS IN ALLOWED RANGE
 480 Y=Y+DY:REM ADD DELTA Y TO Y
 485 POKEVIC+16,SIDE
 490 POKEVIC,X:REM PUT NEW X VALUE INTO SPRITE 0'S X POSITION
 510 POKEVIC+1,Y:REM PUT NEW Y VALUE INTO SPRITE 0'S Y POSITION
 520 GETA$:REM GET A KEY FROM THE KEYBOARD
 521 IFA$="M"THENPOKEVIC+28,1:REM USER SELECTED MULTICOLOR
 522 IFA$="H"THENPOKEVIC+28,0:REM USER SELECTED HIGH RESOLUTION
 530 GOTO340
 600 REM ***** SPRITE DATA *****
 610 DATA64,0,1,16,170,4,6,170,144,10,170,160,42,170,168,41,105,104,169
 620 DATA235,106,169,235,106,169,235,106,170,170,170,170,170,170,170,170
 630 DATA170,170,170,170,166,170,154,169,85,106,170,85,170,42,170,168,10
 640 DATA170,160,1,0,64,1,0,64,5,0,80,0

[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated May 12, 2002.