Author Topic: Help with bullets  (Read 1922 times)

0 Members and 1 Guest are viewing this topic.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Help with bullets
« on: November 02, 2011, 08:38:36 pm »
I can't get my bullet code to work. Well.... here it is.

Code: [Select]

:.Assigning values outside of main loop
:40→S→T
:For(V,0,5)
:0→{V*5+L5}→{V*5+L5+3}
:End

Repeat getKey(15)

.A bunch of stuff

:If getKey(54)
:.Checks if T=S (Vars that check the spacing between the bullets)
:If T=S
:For(V,0,5)
:!If {V*5+L5}=1
:.{V*5+L5} tells if the bullet is ready to fire
:1→{V*5+L5}
:0→T
:. Resets the bullet spacing var
:Goto X
:End
:End
:End
:End
:Lbl X

:.Other stuff

:For(V,0,5)
:. Checks if bullet has been fired and assigns X and Y for bullet
:If {V*5+L5}=1
:X+4→{V*5+L5+1}
:Y+1→{V*5+L5+2}
:Pt-On({V*5+L5+1},{V*5+L5+2},Pic2
:. {V*5+L5+1} says that the bullet has been set up and will now start travelling
:1→{V*5+L5+3}
:2→{V*5+L5}
:. R assigns the direction of travel
:R→{V*5+L5+4}
:End
:End
:For(V,0,5)
:. Will now check if bullet is ready to move
:If {V*5+L5+3}
:. Will check whether to move left or right
:If {V*5+L5+4}
:{V*5+L5+1}+I→{V*5+L5+1}
:Else
:{V*5+L5+1}-I→{V*5+L5+1}
:End
:Pt-On({V*5+L5+1},{V*5+L5+2},Pic2)
:End
:End
:For(V,0,5)
:. Will check if the bullet has gone off the screen.
:If {V*5+L5+1}=1 or {V*5+L5+1}>90
:. Resets the shoot check and gives the X,Y coordnates a number that is off the screen.
:0→{V*5+L5}→{V*5+L5+3}+100→{V*5+L5+1}→{V*5+L5+2}
:End
:End

:. Other stuff

:If T<S
:. Adds 1 to the bullet spacing var
:T++
:End
:DispGraph
:. End main loop
:End

If anyone can spot an error, please tell me!  :)


Edit: I found the error. When I said

:!If {V*5+L5}=1

It would also run if {V*5+L5}=2, but it only needs to run if it equals 0.
« Last Edit: November 02, 2011, 09:48:15 pm by epic7 »