Original Post
I'm having trouble figuring out how to manage my array of objects to "fire" independantly of one-another without all moving at the same time ontop of eachother :/.
The issue isn't setting up the array, nor getting (all) objects to move on keypress, but I'm trying to figure out how to manage the array so that when I press the key only 1 at a time moves (like bullets).
i++ in the code wont display for some reason.
I know I'm rendering all the lasers at once, but I require some guidance on how to render 1 at a time each time the fire laser is true.
The issue isn't setting up the array, nor getting (all) objects to move on keypress, but I'm trying to figure out how to manage the array so that when I press the key only 1 at a time moves (like bullets).
struct Laser{ float xLaserPos; float yLaserPos; //bool Collide; //bool visible; };Laser *LaserArray=NULL;bool FireLaser=false;bool CannotFire=false;NumLasers=50;LaserArray = new Laser[NumLasers];for (int i=0; i<NumLasers;i ++){ LaserArray.xLaserPos = 0; LaserArray.yLaserPos = 0; //LaserArray.visible = false; //LaserArray.Collide = false; }// Render Logic //if (FireLaser == true){// -1 Everytime we fire is true from laser array value int i;i = NumLasers;i-=1; // Render Laser Sprite Laser->Sprite(LaserArray.xPos,LaserArray.xLaserPos,LaserArray.yLaserPos); // Move LaserArray.xLaserPos +=10;// OutOfLaserif(i<=0){ CannotFire=true; }}if((SPACE_PRESSED)&&(CannotFire=false)){FireLaser=true;}i++ in the code wont display for some reason.
I know I'm rendering all the lasers at once, but I require some guidance on how to render 1 at a time each time the fire laser is true.