Hello again Fellow Game Designers!
I have just finished another exercise from the "Beginner's Guide to Dark Basic" entitled, "ShootingGallary Program" however I'm getting an error message when I go to run it. It will compile but when I run it, I get error message #501 Image Number illegal at line 21. If someone could explain this error and tell me how to fix it, that would be great.
Rem Project: ShootingGallery Program
Rem Created: Tuesday, February 28, 2012
Rem Designer: Andrew D. South
Rem ***** Main Source File *****
SYNC ON
SYNC RATE 30
DIM SPRITEHIT(20)
DIM SPRITETIMER(1)
HIDE MOUSE
SPRITETIMER(1) = 0
LOAD IMAGE "Media\crosshair.bmp",25
LOADTARGETANIMS()
`Initialize all the sprites
FOR X = 2 TO 20
SPRITE X,-100,68,5
SET SPRITE x,1,1
SPRITEHIT(x) = 0
NEXT X
`Set the mouse cursor Sprite
SPRITE 1,320,240,1
SET SPRITE 1,1,1
`Setting up the lines in the background
SET CURRENT BITMAP 0
GREEN = RGB(0,0,255)
RED = RGB(255,0,0)
BLACK = RGB(0,0,0)
WHITE = RGB(255,255,255)
INK GREEN,BLACK
BOX 0,98,639,100
INK RED,BLACK
BOX 0,100,639,100
INK WHITE,BLACK
inum = 5
TEXT 10,400,"Click on the target to destroy it!"
`Play the game until the Escape key is hit.
WHILE ESCAPEKEY()=0
PROCESSSPRITES()
CONTROLLERHANDLER()
SYNC
ENDWHILE
END
`This moves the crosshairs to where the mouse it
FUNCTION CONTROLLERHANDLER()
SPRITE 1, MOUSEX(), MOUSEY(), 25
IF MOUSECLICK()=1
FOR X = 2 TO 20
IF SPRITE COLLISION(1,X)
SPRITEHIT(X) = 1
ENDIF
NEXT X
ENDIF
ENDFUNCTION
`This does all the Sprite Collision processing
FUNCTION PROCESSSPRITES()
SPRITETIMER(1) = SPRITETIMER(1) - 1
IF SPRITETIMER(1) <= 0 THEN MOVENEWSPRITE()
FOR X = 2 TO 20
IF SPRITE X(X) > 704
SPRITE X,-100,68,5
SPRITEHIT(X) = 0
ENDIF
IF SPRITEHIT(X)
SPRITE X, SPRITE X(x)+5,SPRITE Y(X), SPRITE IMAGE(X)+1
IF SPRITE IMAGE(X) >= 15
SPRITE X, -100,68,5
SPRITEHIT(X) = 0
ENDIF
ELSE
IF SPRITE X(X) >= -64
SPRITE X,SPRITE X(x)+5,SPRITE Y(X), 5
ENDIF
ENDIF
NEXT X
ENDFUNCTION
`Moves out a new sprite
FUNCTION MOVENEWSPRITE()
FOR X = 2 TO 20
IF SPRITE X(X) <= -100
SPRITE X , -64, SPRITE Y(X), 5
X = 21
ENDIF
NEXT X
SPRITETIMER(1) = 30
ENDFUNCTION
`Loads are the Target Animations
FUNCTION LOADTARGETANIMS()
LOAD BITMAP "Media\Target.bmp",1
inum = 5
fadestep = 100
SET CURRENT BITMAP 1
FOR X = 0 TO 10
FADE BITMAP 1,90
GET IMAGE inum,0,0,64,64
inum = inum + 1
NEXT X
DELETE BITMAP 1
SET CURRENT BITMAP 0
ENDFUNCTION
When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!