Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);


share|improve this question

closed as too localized by msell, Anko, Byte56, bummzack, Trevor Powell Apr 30 '13 at 13:03

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

What are you trying to achieve with "x*tileWidth+x". What is the +x supposed to do? – AB. Apr 29 '13 at 10:18
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? – Tetrad Apr 30 '13 at 7:52

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 :)

share|improve this answer

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

share|improve this answer
I added an edit for your answer, but I don't really understand what you're trying to say... – Liosan Apr 29 '13 at 10:00
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. – ZeroPhase Apr 29 '13 at 10:14

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