I thought for sure I had figured out the challenge to add nebulae[i].pos.x to the for loop. This challenge id described at the 7 minute mark in the video. My code didn’t match the answer exactly but it did have the intended effect. All nebulas appear and move across the screen as you would expect. But it also has as completely unintended consequence. My version of the code makes scarfy totally disappear. This is a tough one to figure out. I tried the instructor’s code… everything works. I use my code and scarfy disappears. Here’s my for loop:
const int sizeOfNebulae{6};
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.width/8;
nebulae[i].pos.y = windowDimensions[1] - nebula.height/8;
nebulae[i].frame = 0;
nebulae[i].runningTime = 0.0;
nebulae[i].updateTime = 0.0;
nebulae[i].pos.x = windowDimensions[0] += 300;
}
The only difference is the last line. Here is the instructors last line:
nebulae[i].pos.x = windowDimensions[0] + i * 300;
It seems like my code, even if it causes slightly different behavior on the nebula, shouldn’t have any effect at all on scarfy.