Problems with Types

Blitz3D Forums/Blitz3D Beginners Area/Problems with Types

That's right! I'm converting my Arrays to Types!
But I have a few minor problems.
Here's the code:
Type bullet
Field count
Field shape
End Type

ammo.bullet=New bullet
ammo\count=100
ammo\shape=LoadSprite("Shot 1.bmp")
ScaleSprite ammo\shape,.2,.2
EntityType ammo\shape,type_missile
EntityRadius ammo\shape,.02
HideEntity ammo\shape

Type target
Field count
Field shape
End Type

For x=1 To 5
For z=1 To 5
foe.target=New target
foe\count=25
foe\shape=CreateCube()
ScaleEntity foe\shape,2,2,2
PositionEntity foe\shape,Rand(-600,800)+x*5,60,Rand(-600,800)+z*5
EntityType foe\shape,type_target
EntityRadius foe\shape,5,5
NameEntity foe\shape,Handle(foe) ;<<<I’m not quite sure why I put this in here
Next
Next

While Not KeyDown(1)

;Firing Bullets
If MouseHit(1) And reload=0
EntityParent ammo\shape,gun
PositionEntity ammo\shape,1,-7,10
RotateEntity ammo\shape,0,90,0
ShowEntity ammo\shape
EntityParent ammo\shape,0
PlaySound SOUNDbam
ammo\count=ammo\count-1
EndIf

bulletpath(ammo.bullet,foe.target)

UpdateWorld
RenderWorld
Flip
Wend
End

Function bulletpath(ammo.bullet,foe.target)
MoveEntity ammo\shape,.043,-.025,2.5
If CountCollisions(ammo\shape)>0
HideEntity ammo\shape
Else
entity=EntityCollided(ammo\shape,type_target)=True;If EntityCollided(ammo\shape,type_target)=True Then
foe.target=Object.target(EntityName(entity));<<<Not quite sure about this either
HideEntity foe\shape
HideEntity ammo\shape
EndIf
End Function

So here are the problems:

1) It keeps reusing the same bullet when I fire (that's my assumption)

2) It keeps saying "Entity Does Not Exist" and it points to this line:
foe.target=Object.target(EntityName(entity))

I'm not completely sure why I put those lines in there. But I thought it would fix the issue of nothing happening when my bullets collided with the target.

Also, I have set up everything else on the line of "type_target" and such.