Forget linepick - he just want to get rid of the array index error which noone seems to have addressed.
Note that you don't need to load the bullet sprite 20 times - load it once and use that as a blueprint for the others. The same applies to the sound, load it once as a global and re-use it as and when required.
There are better ways to do this but I didn't want to re-write all your code. The following should sort your array index issue though :
Note that you don't need to load the bullet sprite 20 times - load it once and use that as a blueprint for the others. The same applies to the sound, load it once as a global and re-use it as and when required.
There are better ways to do this but I didn't want to re-write all your code. The following should sort your array index issue though :
Const type_target=1 Const type_missile=2 Global SOUNDbam = LoadSound("Plasma Gun.wav" ) ;Ceating the bullets Global BULLET = LoadSprite("Shot 1.bmp") ScaleSprite BULLET,.2,.2 EntityType BULLET,type_missile EntityRadius BULLET,.02 HideEntity BULLET Global fullmag=100 Dim bullet( fullmag-1 ) For i = 0 To fullmag-1 bullet(i)= CopyEntity( BULLET ) HideEntity bullet(i) Next ;Creating the targets with an array Global targets = 20 Dim target_one( targets-1) For x = 0 To targets-1 target_one(x)=CreateCube() PositionEntity target_one(x),Rand(-600,800)+x*5,60,Rand(-600,800) ScaleEntity target_one(x),2,2,2 EntityType target_one(x),type_target Next Collisions type_missile,type_target,2,1 While Not KeyDown(1) ;Firing bullets If MouseHit(1) And reload = 0 EntityParent bullet(t),gun PositionEntity bullet(t),1,500,-10 RotateEntity bullet(t),-90,0,0 ShowEntity bullet(t) EntityParent bullet(t),0 t=t+1 PlaySound SOUNDbam EndIf bulletpath() UpdateWorld RenderWorld Flip Wend End ;==================================================================== ;==================================================================== ;==================================================================== Function bulletpath() For q = 0 To fullmag-1 MoveEntity bullet(q),.02,.04,2.5 If CountCollisions(bullet(q)) > 0 HideEntity bullet(q) Else For x = 0 To Targets-1 If EntityDistance(bullet(q),target_one(x)) <= 1 HideEntity target_one(x) EndIf Next EndIf Next End Function