Hi, I'm pretty new to programming and I'm stuck with an assignment.
I'm trying to place blocks in an array in a line for barriers along the sides of the view port.
for (int i = 0; i < BLOCKCOUNT; i++)
{
_block[i]->texture = new Texture2D();
_block[i]->texture->Load("Textures/block.png", true);
for (int j = 0; j < 1024; j++)
{
_block[i]->posRect = new Rect(j, 0.0f, 32, 32);
}
}
The blocks are 32x32 and they always end up in the same place outside of the view port.
I'd really appreciate some guidance on how to fix this.
Thanks.
shouldn't the Rect() take a variable ? Something like
Rect(j,0.0, 32+32*i, 32); //assumption, moving 32 pixels in the x axis for each loop iteration
also, there is a graphical issue where putting things at exact locations can, at some angles on some platforms, give a tiny gap that is visually bad. You can correct for this by jamming them together, like using 31*i instead of 32. This is like where you look at a 90 degree corner of a wall in a house and can see through it sometimes...
or if I misread that and 32 is just the texture size,
it might be j*32, 0.0, 32,32 ??