Sign in to follow this  
Boaty

Using RECT arrays to display a set about of brick sprites

Recommended Posts

Hi all, I'm quite confused on a game I've been developing recently. It's just a simple ball and paddle game. Common names such as Breakout, Brick Break, Breakin' Bricks, and so on. I have practically everything figured out, but I just can't figure out how to display a set amount of bricks on the screen in a uniform patten (pretty much rectangle design). So far I declared the RECT array as such: RECT bricks[NUMBRICKS]; NUMBRICKS I have earlier defined as 100, thus 100 bricks in the array. I've successfully loaded the block sprite into the game, and actually was able to display a single block (although I haven't added any collision detecting yet, I'm fairly certain I know how). Here is the RECT array coding I have: //draw the bricks RECT bricks[NUMBRICKS]; D3DXVECTOR3 position(SCREEN_WIDTH/2-brick.x,100,0); int n; for (n=0; n<NUMBRICKS; n++) { bricks[n].left = brick.x + brick.x; bricks[n].top = brick.y + brick.y; bricks[n].right = brick.x + brick.width-brick.width; bricks[n].bottom = brick.y + brick.height-brick.height; sprite_handler->Draw( brick_image, NULL, NULL, &position, D3DCOLOR_XRGB(255,255,255)); } and here is the SPRITE declare coding: //brick sprite LPDIRECT3DTEXTURE9 brick_image; SPRITE brick; All this manages to do though is display a single block in the screen. Can anyone help me display my block sprite in a rectangular pattern?

Share this post


Link to post
Share on other sites
Ok.


Here is the code I have now. The position variable is inside the loop, but it does not seem to be changing...

//draw the bricks
RECT bricks[NUMBRICKS];

int n, posy=SCREEN_HEIGHT/2-brick.y, posx=SCREEN_WIDTH/2-brick.x;
for (n=0; n<NUMBRICKS; n++)
{
D3DXVECTOR3 position(posx,posy,0);
sprite_handler->Draw(
brick_image,
NULL,
NULL,
&position,
D3DCOLOR_XRGB(255,255,255));
posx += SCREEN_WIDTH/2-brick.x;
posy += SCREEN_HEIGHT/2-brick.y;
}

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this