Challenge to nebulae[i].pos.x lesson 46

The first thing that came to mind for the solution was this code…these challenges are very inspiring

const int sizeOfNebulae{6};                   //Challenge lesson 46 cpp corse 
                                             //set sizeOfNebulae to 6 value
AnimData nebulae[sizeOfNebulae]{};        

for (int i = 0; i < sizeOfNebulae; i++)
{
    nebulae[i].rec.x = 0.0;
    nebulae[i].rec.y = 0.0;
    nebulae[i].rec.width = nebula.width/8;
    nebulae[i].rec.height = nebula.height/8;
    nebulae[i].pos.y = windowDimensions[1] - nebula.height/8;
    nebulae[i].frame = 0;
    nebulae[i].runningTime = 0;
    nebulae[i].updateTime = 1.0/1.6;
}

//Challenge lesson 46 - I created a for loop dedicated to increasing by 300 at each iteration

int increment{0};     //Challenge lesson 46 - I created a for loop dedicated to
                      //increasing by 300 at each iteration           
                                             
for (int i = 0; i < sizeOfNebulae; i++)                                 
{
    nebulae[i].pos.x = windowDimensions[0] + increment;
    increment +=300;
}

RedM3tal

Privacy & Terms