You really should read up on classes. They are one of the most useful objects in C++. Anyway, you don't have to use a class (though it's recommended). Try making two spheres and placing them at the wings. Make an array of integers about [200]. Each time you fire, "instance" the two spheres with two of the integers you just made, use "dbSetObjectToObjectOrientation(Obj1,Obj2)" to make them face the same direction as the plane, then each time you loop, check the [200] for "dbObjectExist(Obj)" and then "dbMoveObject(Obj,speed)". When it hits or gets too far away from the plane, "dbDeleteObject(Obj)". This is made much simpler with an class, with the same concept:
class BULLET{
public:
bool Active;
int BulletMesh;
long Time;//this is so you can make it "not Active" when it's been out too long
};
Make the bullets before the GDKLoop():
int BulletCount=0;//to keep track of your bullets
dbMakeObjectSphere(1,0.1);//small bullets
BULLET Bullet[200];
Bullet[0].BulletMesh=1;
Bullet[0].Active=false;
dbExcludeObjectOn(Bullet[0].BulletMesh);//so it doesn't show
for (int i=1;i<200;i++){
Bullet[i].Active=false;
Bullet[i].BulletMesh=i;
dbInstanceObject(Bullet[i].BulletMesh,1);
dbExcludeObjectOn(Bullet[i].BulletMesh);//so it doesn't show
}
When you fire:
dbPositionObject(Bullet[BulletCount].BulletMesh,wing1x,wing1y,wing1z);
dbExcludeObjectOff(Bullet[BulletCount].BulletMesh);
Bullet[BulletCount].Time=0;
Bullet[BulletCount].Active=true;
dbSetObjectToObjectOrientation(Bullet[BulletCount].BulletMesh,Plane);
dbPositionObject(Bullet[BulletCount+1].BulletMesh,wing2x,wing2y,wing2z);
dbExcludeObjectOff(Bullet[BulletCount+1].BulletMesh);
Bullet[BulletCount+1].Time=0;
Bullet[BulletCount+1].Active=true;
dbSetObjectToObjectOrientation(Bullet[BulletCount+1].BulletMesh,Plane);
BulletCount+=2;
if (BulletCount>199) BulletCount-=200;
Each time you loop:
for (int i=0;i<200;i++){
if (Bullet[i].Active){
dbMoveObject(i,speed);
Bullet[i].Time+=1;//I would set up a time-between-frames for better movement.
if (Bullet[i].Time>1000){
dbExcludeObjectOn(Bullet[i].BulletMesh);//so it doesn't show
Bullet[BulletCount].Active=false;
}
}
}
The fastest code is the code never written.