4 way shooting

Blitz3D Forums/Blitz3D Beginners Area/4 way shooting

I'm trying to make a 4 way shooting system for a test game... for some reason, I cant get the thing to work... here's the code:


first, the actions

If KeyDown(200) Then MoveEntity bob,0,0,.1: RotateMesh bob,3,0,0: fire_angle=1
If KeyDown(208) Then MoveEntity bob,0,0,-.1: RotateMesh bob,-3,0,0: fire_angle=2
If KeyDown(205) Then MoveEntity bob,.1,0,0: RotateMesh bob,0,0,-3: fire_angle=3
If KeyDown(203) Then MoveEntity bob,-.1,0,0 RotateMesh bob,0,0,3: fire_angle=4

If KeyHit(54) And fire_angle=1 Then create_bullet_up
If KeyHit(54) And fire_angle=2 Then create_bullet_down
If KeyHit(54) And fire_angle=3 Then create_bullet_left
If KeyHit(54) And fire_angle=4 Then create_bullet_right

For b.bullet= Each bullet
update_bullet_up
update_bullet_down
update_bullet_left
update_bullet_right
Next 


then, the functions:

Function create_bullet_up()
b.bullet=New bullet
b\direct=1
b\entity=CopyEntity(bullet)
PositionEntity b\entity,EntityX(bob),EntityY(bob),EntityZ(bob)
End Function

Function create_bullet_down()
b.bullet=New bullet
b\direct=2
b\entity=CopyEntity(bullet)
PositionEntity b\entity,EntityX(bob),EntityY(bob),EntityZ(bob)
End Function

Function create_bullet_left()
b.bullet=New bullet
b\direct=3
b\entity=CopyEntity(bullet)
PositionEntity b\entity,EntityX(bob),EntityY(bob),EntityZ(bob)
End Function

Function create_bullet_right()
b.bullet=New bullet
b\direct=4
b\entity=CopyEntity(bullet)
PositionEntity b\entity,EntityX(bob),EntityY(bob),EntityZ(bob)
End Function


Function update_bullet_up()
For b.bullet=Each bullet
If b\direct=1 Then MoveEntity b\entity,0,0,1
Next
End Function

Function update_bullet_down()
For b.bullet=Each bullet
If b\direct=2 Then MoveEntity b\entity,0,0,-1
Next
End Function

Function update_bullet_left()
For b.bullet=Each bullet
If b\direct=3 Then MoveEntity b\entity,1,0,0
Next
End Function

Function update_bullet_right()
For b.bullet=Each bullet
If b\direct=4 Then MoveEntity b\entity,-1,0,0
Next
End Function