[SOLVED]Help with SDL/C++ Space Invaders Clone
Posted: Mon Jun 08, 2009 9:11 pm
Hey Everyone,
First time poster here. Please no hazing
I'm a user over at gamedev.net as well, and while that is admittedly an excellent resource, I haven't been able to get any bites on help with this problem. Here is the context of my last post of this problem on gamedev.net. To see the whole thread check here http://www.gamedev.net/community/forums ... _id=537113. Thanks in advance for anyone who can shed some light on this for me.
------------------------------
Alrighty, ran into another problem. Now that I can draw my array of surfaces I want to test removing individual blocks from the screen. To do this I basically construct an equally sized array of integers, and set all values to 1.
Once this is done, during the draw function I loop through this array and check to see if any values == 0. If they do, don't draw that block. But for some reason this is only working with elements in the [0][x] section of the array. Any other value of Y and it fails.
So basically, I can only affect the top row of blocks with this method. I must be missing something minor here as the top row works exactly as intended.
-----------------------------------------------
First time poster here. Please no hazing
I'm a user over at gamedev.net as well, and while that is admittedly an excellent resource, I haven't been able to get any bites on help with this problem. Here is the context of my last post of this problem on gamedev.net. To see the whole thread check here http://www.gamedev.net/community/forums ... _id=537113. Thanks in advance for anyone who can shed some light on this for me.
------------------------------
Alrighty, ran into another problem. Now that I can draw my array of surfaces I want to test removing individual blocks from the screen. To do this I basically construct an equally sized array of integers, and set all values to 1.
Code: Select all
blocks::blocks()
{
for(int blockY = 0; blockY < 5; blockY++)
{
for(int blockX = 0; blockX < 8; blockX++)
{
blocksAlive[blockY][blockX] = 1;
}
}
for(int blockY = 0; blockY < 5; blockY++)
{
for(int blockX = 0; blockX < 8; blockX++)
{
blocksArray[blockY][blockX] = block;
}
}
}
Once this is done, during the draw function I loop through this array and check to see if any values == 0. If they do, don't draw that block. But for some reason this is only working with elements in the [0][x] section of the array. Any other value of Y and it fails.
Code: Select all
void blocks::drawblocks()
{
for(int drawY = 0; drawY < 5; drawY++)
{
for(int drawX = 0; drawX < 8; drawX++)
{
if(blocksAlive[drawY][drawX] == 0)
{
continue;
}
switch(drawY)
{
case 0:
apply_surface(((SCREEN_WIDTH / 8) - (BLOCK_WIDTH / 2)) * (drawX + 1), 40, blocksArray[drawY][drawX], screen, NULL);
case 1:
apply_surface(((SCREEN_WIDTH / 8) - (BLOCK_WIDTH / 2)) * (drawX + 1), 80, blocksArray[drawY][drawX], screen, NULL);
case 2:
apply_surface(((SCREEN_WIDTH / 8) - (BLOCK_WIDTH / 2)) * (drawX + 1), 120, blocksArray[drawY][drawX], screen, NULL);
case 3:
apply_surface(((SCREEN_WIDTH / 8) - (BLOCK_WIDTH / 2)) * (drawX + 1), 160, blocksArray[drawY][drawX], screen, NULL);
case 4:
apply_surface(((SCREEN_WIDTH / 8) - (BLOCK_WIDTH / 2)) * (drawX + 1), 200, blocksArray[drawY][drawX], screen, NULL);
}
}
}
}
-----------------------------------------------