drawing bricks

Started by
6 comments, last by empirical2 13 years, 6 months ago
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.
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?
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.
I'm confused, so does the code above work or not? If not, is count being initialized to zero on each call?
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.
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)
they just flash one time.
Are you sure you draw the blocks every single frame?

(TBH, gonna need more code to go any further)

This topic is closed to new replies.

Advertisement