Evil Inside,
Let's start with the bullets part of the gun. Below I have placed a code snippet of a fully runnable program. It is 2D, and completely convertable to 3D, just by adding a third dimension. The first dimension holds the bullets' x positions, second their y position, third their angle of movement, and fourth their bulletlife.
I have calculated how many bullets(array slots) I need in order that the bullets do no 'run out'. To say otherwise, that the bullets will keep a consitent flow with no funky gaps. The code is heavily commented, hopefully enough for you to understand its processes. If you do not, just ask a specific question or more, and I will help you to understand. Enjoy.
I have made an array, which has sixty slots, and four dimensions in each slot.
set display mode 800,600,32
sync on
sync rate 60
REM << this will be the array, storing the bullets' information(60 bullets, 4 dimensions of info each)
REM << there is no need to fill the array with information until the bullet needs to be fired
REM << dimension 1 = xcoord;slot,dimension 2 = ycoord;dimension 3 = angle;dimension 4 = bulletlife
dim bullet(60,4)
REM << prepare count2 for game, since there is no 0 slot in the array, or 0 number of bullet
count2 = 1
REM << pre-position player in center of screen
playerx# = 400
playery# = 300
REM <<<<<<<< main loop >>>>>>>>>
repeat
REM << enable the player to shoot a bullet
if mouseclick() = 1
REM << count1 is our delay variable, will only allow a bullet to be shot when its value = 5
inc count1
if count1 = 5
REM << reset count1 for next delay
count1 = 0
REM << count2 is incremented after each delay and used as which dimension in the array to be edited(lamen:which bullet is being fired)
inc count2
REM << if count2 goes above the amount of bullets(in this case 60, then reset it to 1)to continue fluid loop of bullets moving
if count2 > 60 then count2 = 1
REM << now, let's prepare the bullet, # of count2, which is going to be fired, by setting its array slot/dimension properties
bullet(count2,1) = playerx# + (cos(playerangle) * 20)
bullet(count2,2) = playery# + (sin(playerangle) * 20)
REM << store the present angle of the player to be the bullets angle of direction
bullet(count2,3) = playerangle
REM << set its bulletlife to 300(now, the bullet will move since its life is above 0, see below)
bullet(count2,4) = 300
endif
endif
REM << this is where we use bulletlife to move the bullet, that if it is above 0 then move the bullet
REM << we'll use a for next loop to decide which bullets to move(check if its life is above zero, if so then move it)
for t = 1 to 60
REM << check to see if the bullet's life is valued above 0
if bullet(t,4) > 0
REM << if above 0 then the bullet is 'active' so then make it move according to its angle of direction
bullet(t,1) = bullet(t,1) + (cos(bullet(t,3)) * 5)
bullet(t,2) = bullet(t,2) + (sin(bullet(t,3)) * 5)
REM << decrement bulletlife
bullet(t,4) = bullet(t,4) - 1
endif
next t
REM << don't focus on this section, its just the player movement and screen displaying
if rightkey() = 1 then playerangle = wrapvalue(playerangle + 1)
if leftkey() = 1 then playerangle = wrapvalue(playerangle - 1)
if upkey() = 1
inc playerx#,(cos(playerangle) * 2)
inc playery#,(sin(playerangle) * 2)
endif
REM << draw to screen
ink rgb(0,0,255),0
circle playerx#,playery#,10
line playerx# + (cos(playerangle) * 10),playery# + (sin(playerangle) * 10),playerx# + (cos(playerangle) * 20),playery# + (sin(playerangle) * 20)
REM << instructions
ink rgb(255,255,255),0
text 0,0,"Use arrow keys to move character"
text 0,15,"Press left mouse button to fire weapon"
text 0,30,"Press right mouse button to end program"
REM << draw bullets to screen
ink rgb(255,0,0),0
for t = 1 to 60
if bullet(t,4) > 0 then dot bullet(t,1),bullet(t,2)
next t
sync
cls
until mouseclick() = 2
end

+NanoBrain+