d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(0,0,0));
//copy the surface to the backbuffer
Sleep(50);
RECT recta;//blank
recta.left = x3+=20;//370
recta.right = x4+=20;//390
recta.top = y1-=20;//310
recta.bottom = y2-=20;//330
d3ddev->StretchRect(surface, NULL, backbuffer, &recta, D3DTEXF_NONE);
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(255,255,255));
//copy the surface to the backbuffer
Sleep(50);
RECT rectb;//colored
rectb.left = x1+=20;//390
rectb.right = x2+=20;//410
rectb.top = y3-=20;//290
rectb.bottom = y4-=20;//310
d3ddev->StretchRect(surface, NULL, backbuffer, &rectb, D3DTEXF_NONE);
if(rectb.top <= 150)
{
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(0,0,0));
rect12.left = 400;
rect12.right = 600;
rect12.top = 100;
rect12.bottom = 150;
d3ddev->StretchRect(surface, NULL, backbuffer, &rect12, D3DTEXF_NONE);
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(0,0,0));
//copy the surface to the backbuffer
Sleep(50);
RECT recta;//blank
recta.left = x3+=20;//370
recta.right = x4+=20;//390
recta.top = y1+=20;//310
recta.bottom = y2+=20;//330
d3ddev->StretchRect(surface, NULL, backbuffer, &recta, D3DTEXF_NONE);
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(255,255,255));
//copy the surface to the backbuffer
Sleep(50);
RECT rectb;//colored
rectb.left = x1+=20;//390
rectb.right = x2+=20;//410
rectb.top = y3+=20;//290
rectb.bottom = y4+=20;//310
d3ddev->StretchRect(surface, NULL, backbuffer, &rectb, D3DTEXF_NONE);
}
breakout ball
well here is some code where a ball hits a brick but the brick reappears after it is hit.
umm...
if rectb.top means "the top of the ball", the problem is you are drawing the brick when the ball's top is < 150, otherwise it's not drawn.
So... the ball goes up and hits the brick and it stops drawing til the ball goes back down.
Try this instead...
change:
if(rectb.top <= 150)
to
if(bBrickBroken == false)
and then above that if statement put this:
if(rectb.top <= 150)
bBrickBroken = true;
Also, dont forget to define bBrickBroken as a bool and initialize it to false.
Also, off topic, but why the sleep(50)'s?
if rectb.top means "the top of the ball", the problem is you are drawing the brick when the ball's top is < 150, otherwise it's not drawn.
So... the ball goes up and hits the brick and it stops drawing til the ball goes back down.
Try this instead...
change:
if(rectb.top <= 150)
to
if(bBrickBroken == false)
and then above that if statement put this:
if(rectb.top <= 150)
bBrickBroken = true;
Also, dont forget to define bBrickBroken as a bool and initialize it to false.
Also, off topic, but why the sleep(50)'s?
Quote:Original post by phil67rpg
I know need to know how to get the ball to bounce off the invisible brick.
If it hits the top or bottom, negate the y component of its velocity. If it hits the sides, negate the x component.
To "negate" a number means to replace it with the negative of that value. In other words, to subtract it from zero, or multiply it by -1.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement