• Advertisement
Sign in to follow this  

drawing bricks

This topic is 2684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

well I am using an array to draw bricks for a breakout game.I am using directx9 and c++. However when drawing to the screen the bricks flash on and off. I put the code in the Game_Run function of the program.

for(int row=150;row<=250;row+=50)
{
for(int col=0;col<=600;col+=200)
{
count++;

if(count>=1 && count<=4)
{
RECT rect;
rect.left=col;
rect.right=col+200;
rect.top=row-50;
rect.bottom=row;
//draw surface to the backbuffer
d3ddev->StretchRect(surface, NULL, backbuffer, &rect, D3DTEXF_NONE);
}
if(count>=5 && count<=8)
{
RECT rect;
rect.left=col;
rect.right=col+200;
rect.top=row-50;
rect.bottom=row;
//draw surface to the backbuffer
d3ddev->StretchRect(surface_two, NULL, backbuffer, &rect, D3DTEXF_NONE);
}
if(count>=9 && count<=12)
{
RECT rect;
rect.left=col;
rect.right=col+200;
rect.top=row-50;
rect.bottom=row;
//draw surface to the backbuffer
d3ddev->StretchRect(surface_three, NULL, backbuffer, &rect, D3DTEXF_NONE);
}

}
}


it has something to do where I put the array in the program.I notice when I attempt to draw the bricks they are drawn properly they just stay on the screen.

Share this post


Link to post
Share on other sites
Advertisement
Well if you put the array inside a function that is called and exits every frame then the array will fall out of scope unless you declare it as static.

Is that what you mean?

Share this post


Link to post
Share on other sites
I am sorry but I took the arrays out of my code I am using only for and if statements.I stubbed the code in another program and the values seem to work out ok.

Share this post


Link to post
Share on other sites
It does work.It just flashes to the screen and then disappers.Sorry for the confusion.I initialize count out side of the loop which I set to zero.

Share this post


Link to post
Share on other sites
Quote:
I notice when I attempt to draw the bricks they are drawn properly they just stay on the screen.


Im guessing that is supposed to be "just DON'T stay on the screen"? (That was confusing me lol)

If so, do they flash on and off really fast (flickering)? If so I would suspect maybe you are only drawing to one buffer and not the other? (I haven't used DX for a long time)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement