-1
\$\begingroup\$

i am trying to create breakout. code below loop though my 2d array(map) and creates bricks. the problem is that i want to add 10 pixels space between each bricks. i was thinking to add x*titleWidth+x+10 in side blockobject but it moves all of the bricks and there is no space in between. any ideas?

for (int y = 0; y < map01.length; y++){  //row
for (int x = 0; x < map01[y].length; x++){ // cols
    if(map01[y][x] == 2){  //Bricks
        blockObject = new Block(x*tileWidth+x, y*tileHeight+y, tileWidth, tileHeight);
    }
}

}

\$\endgroup\$
2
  • 1
    \$\begingroup\$ What are you trying to achieve with "x*tileWidth+x". What is the +x supposed to do? \$\endgroup\$ – AB. Apr 29 '13 at 10:18
  • \$\begingroup\$ What are your constructor parameters? Have you white boarded out the math you're trying to implement? Have you stepped through the code with a debugger? \$\endgroup\$ – Tetrad Apr 30 '13 at 7:52
1
\$\begingroup\$

If you want to add a transparent border to each block, then you need to increase the space needed for each block:

x * (tileWidth + 10) + x

This probably won't be exactly the look you want, but it'll point you in the right direction :)

\$\endgroup\$
-1
\$\begingroup\$

Which view are you working in? I could probably get it to work in XNA, if I knew a bit more about your code.

\$\endgroup\$
2
  • \$\begingroup\$ I added an edit for your answer, but I don't really understand what you're trying to say... \$\endgroup\$ – Liosan Apr 29 '13 at 10:00
  • \$\begingroup\$ Make an object with a vector2 field and set it's X and y position, or have a blank square with a width of 10 inherit from your brick class, and print it out after every brick loop. \$\endgroup\$ – ZeroPhase Apr 29 '13 at 10:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.