whats wrong here

Blitz3D Forums/Blitz3D Beginners Area/whats wrong here

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

for some reason unknown too me i get ( object does not exist ) when i kill an enemy.
Please Help.
theres no media so you can copy and paste to see what i'm talkin about.
*********************************************
Type Player
Field x
Field y
End Type

Type Enemy
Field x
Field y
End Type

Type Bullet
Field x
Field y
End Type

SeedRnd MilliSecs()
Graphics 600,400
SetBuffer BackBuffer()

Global BulletTimer=MilliSecs()

create_player()
create_enemy()

While Not KeyHit(1)

update_player()
update_enemy()
update_bullet()
kills()

Flip
Cls
Wend
End

Function kills() ;NEEDS WORK... BAD REAL BAD
For e.enemy=Each enemy
For b.bullet=Each bullet
If RectsOverlap(e\x,e\y,10,10,b\x,b\y,10,10)
Delete e
End If
Next
Next
End Function

Function create_player()
p.Player=New Player
p\x=300
p\y=350
End Function
Function update_player()
For p.Player=Each Player
Color 100,100,100
Rect p\x,p\y,20,20
If KeyDown(203) p\x=p\x-2
If KeyDown(205) p\x=p\x+2
If KeyHit(57) And MilliSecs()>BulletTime Then Create_Bullet(p\x,p\y)
Next
End Function

Function create_enemy()
For i=1 To 5
e.Enemy=New Enemy
e\x=Rnd(10,500)
e\y=Rnd(10,100)
Next
End Function
Function update_enemy()
For e.Enemy=Each Enemy
Color 200,200,200
Rect e\x,e\y,10,10
Next
End Function

Function create_bullet(x,y)
b.Bullet=New Bullet
b\x=x+5
b\y=y-15
BulletTimer=MilliSecs()
End Function
Function update_bullet()
For b.Bullet=Each Bullet
Color 200,0,0
Rect b\x,b\y,10,10
b\y=b\y-3
If b\y<1 Then Delete b
Next
End Function