Hm, I tried just deleting the sprite, and also fixed up the
IMAGE EXIST functions, but now i'm getting the error: "Runtime Error 302 - Sprite does not exist at line 212"
This is the code i'm compiling now:
REM Project: My First Game - Space Invaders
REM Created: 11-Apr-07 2:07:36 PM
REM
REM ***** Main Source File *****
GOSUB var_dec
var_dec:
plr_lives=3
enemy_hp=20
score=0
tmr#=1
vary=0
resolution=1
resx=800
resy=600
plrx=400
plry=400
enemyx=200
enemyy=200
bulx=plrx
buly=0
GOTO main_menu
main_menu:
SET DISPLAY MODE resx, resy, 32
forground = RGB(255,255,255)
background = RGB(0,0,0)
BACKDROP OFF
SYNC OFF
INK 0,0
CLS
MakeABackground(resx,resy)
MakeMenuButtons()
DO
INK forground,background
PASTE IMAGE 1,0,0
SPRITE 1,resx/2,650,1
LOOP
END
FUNCTION MakeABackground(resx,resy)
LOAD IMAGE "mediammbg.png",1
PASTE IMAGE 1,0,0
ENDFUNCTION
FUNCTION MakeMenuButtons()
INK RGB(255,0,0),0
BOX 350,350,450,370
INK 0,0
BOX 351,351,449,369
INK RGB(255,255,255),0
TEXT 385,352,"Exit"
SET TEXT OPAQUE
SET TEXT TO NORMAL
INK RGB(255,0,0),0
BOX 300,300,400,320
INK 0,0
BOX 301,301,399,319
INK RGB(255,255,255),0
TEXT 315,302,"Load Game"
SET TEXT OPAQUE
SET TEXT TO NORMAL
INK RGB(255,0,0),0
BOX 200,200,300,220
INK 0,0
BOX 201,201,299,219
INK RGB(255,255,255),0
TEXT 215,202,"New Game"
SET TEXT OPAQUE
DO
Mx=MOUSEX(): My=MOUSEY(): Mc=MOUSECLICK()
IF Mx>350 AND My>350 AND Mx<450 AND My<370
If Mc=1
END
ELSE
ENDIF
ELSE
ENDIF
Mx=MOUSEX(): My=MOUSEY(): Mc=MOUSECLICK()
IF Mx>300 AND My>300 AND Mx<400 AND My<320
If Mc=1
GOSUB load_game
ELSE
ENDIF
ELSE
ENDIF
Mx=MOUSEX(): My=MOUSEY(): Mc=MOUSECLICK()
IF Mx>200 AND My>200 AND Mx<300 AND My<220
If Mc=1
GOSUB new_game:
ELSE
ENDIF
ELSE
ENDIF
LOOP
ENDFUNCTION
RETURN
load_game:
` Load the game from a .DAT file here
RETURN
new_game:
CLS
LOAD IMAGE "mediabackdrop.png",2
PASTE IMAGE 2,0,0
LOAD IMAGE "mediaplayer.bmp",3
PASTE IMAGE 3,plrx,plry
LOAD IMAGE "mediabullet.bmp",9
LOAD SOUND "mediathree.wav",3
LOAD SOUND "mediatwo.wav",4
LOAD SOUND "mediaone.wav",5
LOAD SOUND "mediago.wav",6
LOAD MUSIC "mediamusic.mp3",1
TEXT 0,0,"Score: "+str$(score)
TEXT 0,20,"Lives: "+str$(plr_lives)
SLEEP 1000
SET TEXT FONT "Fixedsys"
SET TEXT SIZE 36
TEXT resx/2,resy/2,"3" : PLAY SOUND 3
DO
INC tmr#,1
IF tmr#>220
GOTO two:
ENDIF
IF tmr#>550
GOTO oner
ENDIF
IF tmr#>800
GOTO go
ENDIF
SET TEXT FONT "Fixedsys"
SET TEXT SIZE 36
LOOP
RETURN
two:
time = TIMER()
PLAY SOUND 4
WHILE TIMER() < time + 1000
TEXT resx/2,resy/2,"2"
SYNC
ENDWHILE
oner:
time = TIMER()
PLAY SOUND 5
WHILE TIMER() < time + 1000
TEXT resx/2,resy/2,"1"
SYNC
ENDWHILE
go:
time = TIMER()
PLAY SOUND 6
WHILE TIMER() < time + 1000
TEXT resx/2,resy/2,"Go!"
GOSUB play_game
SYNC
ENDWHILE
play_game:
PLAY MUSIC 1
SET TEXT SIZE 11
LOAD IMAGE "mediaenemy.bmp",10
SPRITE 4,enemyx,enemyy,10
DO
IF UPKEY()=1 THEN plry=plry-1
IF DOWNKEY()=1 THEN plry=plry+1
IF RIGHTKEY()=1 THEN plrx=plrx+1
IF LEFTKEY()=1 THEN plrx=plrx-1
PASTE IMAGE 2,0,0
SPRITE 3,plrx,plry,3
IF SPRITE EXIST (4)
` MOVE THE SPRITE, FIGURE OUT HOW TO MOVE IT RIGHT MOVE SPRITE 4,-.4
ENDIF
TEXT 0,0,"Score: "+str$(score)
TEXT 0,20,"Lives: "+str$(plr_lives)
IF SPACEKEY()=1 AND FiredBullet=0
FiredBullet=1
BulletPosX = plrx + 20
BulletPosY = plry
ENDIF
IF FiredBullet=1
GOSUB move_bullet
ENDIF
LOOP
RETURN
move_bullet:
DEC BulletPosY,5
IF IMAGE EXIST(5)=0
SPRITE 5,BulletPosX,BulletPosY,9
ENDIF
IF SPRITE EXIST(4) AND SPRITE EXIST(5) AND SPRITE COLLISION(5,4)
DELETE SPRITE 4
DELETE SPRITE 5
ENDIF
IF BulletPosY<=0 THEN FiredBullet=0
RETURN