You need an array for the bullet:
» x position
» y position
» x velocity
» y velocity
» counter since bullet was fired
it would look something like this:
DIM BPX[0],BPY[0],BVX[0],BVY[0]
Then to shoot shoot a bullet:
PUSH BPX,gunXPosition
PUSH BPY,gunYPosition
PUSH BVX,SIN(gunAngle*PI()/180)*SPEED
PUSH BVY,COS(gunAngle*PI()/180)*SPEED
make a bullet sprite go to the gun when shot, and then make the bullet go forward until it collides with something or goes a certain distance. Use spcol, spcolvec, sphitsp, spofs, spshow, sphide, and a few variables to do these things.
its simple and complicated.
Well thats when you need to use sine and cosine to convert an angle in degrees to a x velocity and y velocity
It takes a bit of math unfortunately
So lets say the sprites rotation is stored in
VAR ROT
rotate the sprite to that angle with
SPROT SPRITEID,ROT
get the x and y velocities of the bullet with
XVEL=-10*SIN(-ROT*PI()/180)
YVEL=-10*COS(-ROT*PI()/180)
[you might need to tweak]
then you'd move the bullet like so:
X=X+XVEL
Y=Y+YVEL
SPOFS BULLETID,X,Y
Keep in mind these variables should be arrays if you want more than one bullet on the screen at once