shoot arrow

Blitz3D Forums/Blitz3D Beginners Area/shoot arrow

Your error comes from using:

newbolt=CopyEntity(bolt)


At the top of the code, then using it to reference type objects as well.

If Animating(xbow)=0 Then Animate xbow,3 
newbolt.mybolt=New mybolt


Change one of them to a different variable name. You can't have them both called new bolt :)


Your structure for the If's is incorrect in one part.

I'm confused by this line mainly:

If MouseDown (1) = True Then If MouseHit(1) Then 
If Animating(xbow)=0 Then Animate xbow,3 
newbolt.mybolt=New mybolt


Your checking to see if the mouse button has been pressed and held in basically. Best to do this:

If Mousehit (1) = True Then 
   If Animating(xbow)=0 Then Animate xbow,3 
   newbolt.mybolt=New mybolt
End if


See if you indent your code correctly, it helps greatly in tracking down errors. For example:

Graphics 800,600
SetBuffer BackBuffer()
x=100
y=100
While Not KeyHit(1)
Cls
If KeyHit(205) then
x=x+1
If x>700 then
x=x-1
End If
ElseIf KeyHit(203) then
x=x-1
If x<50 then
x=x+1
End If
End If

Rect x,y,5,5
Flip
Wend
End


Compared to:

Graphics 800,600
SetBuffer BackBuffer()

x=100
y=100

While Not KeyHit(1)
   Cls
   If KeyHit(205) then
      x=x+1
      If x>700 then
         x=x-1
      End If
   ElseIf KeyHit(203) then
      x=x-1
      If x<50 then
         x=x+1
      End If
   End If

   Rect x,y,5,5
   Flip
Wend
End


You can clearly see each If and what loop parts of code are in. Makes it easy to track down missing If's as well :)