Hi
Could you read the Galanian_tester_collision_tirs_joueur_et_tirs_ennemis() function. What's happen after the remove(s). Is Galanian_tableau_tirs_ennemis.Length at the FOR line is updated and decrease by one after the remove ?
Correct function ?
(i've some array out of bound errors inside the project... Galanian_tableau_tirs_joueur[i].Sprite, Galanian_tableau_tirs_ennemis[j].Sprite)
Thanks
Function Galanian_tester_collision_tirs_joueur_et_tirs_ennemis()
Local i as Integer
Local j as Integer
For i=0 to Galanian_tableau_tirs_joueur.Length
For j=0 to Galanian_tableau_tirs_ennemis.Length
If GetSpriteExists (Galanian_tableau_tirs_joueur[i].Sprite)
If GetSpriteExists (Galanian_tableau_tirs_ennemis[j].Sprite)
If GetSpriteCollision (Galanian_tableau_tirs_joueur[i].Sprite, Galanian_tableau_tirs_ennemis[j].Sprite)
Galanian_creer_explosion (Galanian_tableau_tirs_ennemis[j].PosX, Galanian_tableau_tirs_ennemis[j].PosY)
DeleteSprite (Galanian_tableau_tirs_joueur[i].Sprite)
DeleteSprite (Galanian_tableau_tirs_ennemis[j].Sprite)
Galanian_tableau_tirs_ennemis.Remove(j)
Galanian_tableau_tirs_joueur.Remove(i)
EndIf
EndIf
Endif
Next
Next
EndFunction
Type Galanian_tir_ennemi_type
InitX as Integer
InitY as Integer
DestinationX as Integer
DestinationY as Integer
PosX as Integer
PosY as Integer
Angle as Integer
Vitesse as Float
Vx as Float
Vy as Float
Sprite as Integer
EndType
Global Galanian_tableau_tirs_ennemis as Galanian_tir_ennemi_type[]
Function Galanian_ennemi_creer_tir (InitX as Integer, InitY as Integer, DestinationX as Integer, DestinationY as Integer, Vitesse as Float)
Local t as Galanian_tir_ennemi_type
t.InitX = InitX
t.InitY = InitY
t.PosX = t.InitX
t.PosY = t.InitY
t.DestinationX = DestinationX
t.DestinationY = DestinationY
t.Vitesse = Vitesse
t.Angle = Atan2 (t.DestinationY - t.InitY, t.DestinationX - t.InitX)
t.Vx = Cos (t.Angle) * t.Vitesse
t.Vy = Sin (t.Angle) * t.Vitesse
t.Sprite = CreateSprite (Galanian_image_tir_ennemi)
SetSpriteOffset (t.Sprite, GetImageWidth (Galanian_image_tir_ennemi)/2, GetImageHeight (Galanian_image_tir_ennemi)/2)
SetSpriteDepth (t.Sprite, 1)
SetSpritePositionByOffset (t.Sprite, t.PosX, t.PosY)
SetSpriteShape (t.Sprite,1)
Playsound (Galanian_son_tir_ennemi)
Galanian_tableau_tirs_ennemis.Insert (t)
EndFunction