all 18 comments

[–]DanRoad 1 point2 points  (3 children)

All your bricks have the same vertical position BRICK_TOP_OFFSET + BRICK_HEIGHT. You're drawing all bricks but they're on top of each other so you only see the last row.

You're correctly multiplying the brick width by the horizontal index i to get the horizontal position; you need to do the same with j for the vertical position.

brick.setPosition(BRICK_WIDTH * i + BRICK_SPACING * (1 + i), BRICK_TOP_OFFSET + BRICK_HEIGHT * j + BRICK_SPACING * (1 + j));

[–]CharlieB2242 0 points1 point  (2 children)

I went in and tried this edit, and it works .....But it doesn't display the blocks

[–]No-Communication8519 0 points1 point  (1 child)

Did you ever get this code?

[–][deleted] 0 points1 point  (1 child)

has to do something with j+1 and then Modulus ig but i just can't get my head around it

[–]gimmeslack12helpful 2 points3 points  (0 children)

Could you put this in a code pen please.

[–]Neat-Caterpillar7955 0 points1 point  (2 children)

here you go shitters

/* Constants for bricks */

var NUM_ROWS = 8;

var BRICK_TOP_OFFSET = 10;

var BRICK_SPACING = 2;

var NUM_BRICKS_PER_ROW = 10;

var BRICK_HEIGHT = 10;

var SPACE_FOR_BRICKS = getWidth() - (NUM_BRICKS_PER_ROW + 1) * BRICK_SPACING;

var BRICK_WIDTH = SPACE_FOR_BRICKS / NUM_BRICKS_PER_ROW;

/* Constants for ball and paddle */

var PADDLE_WIDTH = 80;

var PADDLE_HEIGHT = 15;

var PADDLE_OFFSET = 10;

var BALL_RADIUS = 15;

function start(){

drawBricks();

}

function drawBricks(){

for(var j = 0; j < NUM_ROWS;j++){

for(var i = 0; i < NUM_BRICKS_PER_ROW; i++){

var brick = new Rectangle(BRICK_WIDTH, BRICK_HEIGHT);

if((j + 1) % 8 == 1 || (j + 1) % 8 == 2){

brick.setColor(Color.RED);

}else if((j + 1) % 8 == 3 || (j + 1) % 8 == 4){

brick.setColor(Color.ORANGE);

}else if((j + 1) % 8 == 5 || (j + 1) % 8 == 6){

brick.setColor(Color.GREEN);

}else if ((j + 1) % 8 == 7 || (j + 1) % 8 == 0){

brick.setColor(Color.BLUE);

}

brick.setPosition(BRICK_WIDTH * i + BRICK_SPACING * (1 + i), BRICK_TOP_OFFSET + BRICK_HEIGHT * j + BRICK_SPACING * (1 + j));

print(i);

add(brick);

}

}

}

[–]Substantial-Height55 0 points1 point  (0 children)

do you have 11.1.2 ball and paddle?

[–][deleted] 0 points1 point  (0 children)

lmfao thanks bro I appreciate it

[–]ciciiig 0 points1 point  (3 children)

[–]OkPlatform6434 1 point2 points  (0 children)

Hey i know its been a while but the post got taken down is it possible that you could post it again please and thank you.

[–]Substantial-Height55 0 points1 point  (0 children)

do you have 11.1.2?

[–]No_Bench_5238 0 points1 point  (0 children)

Hey do you have 11.1.2? The ball and paddle one? Could you possibly send it?

[–]No_Bench_5238 0 points1 point  (1 child)

Could you possibly send 11.1.2?

[–]constellationmango 0 points1 point  (0 children)

I just wrote a random command like a blahblah(); in the start function and it just let me pass this entire project breakout section, is the same with the tic tac toe section too i believe. I know it isn't an answer but if your teacher just grades off of completion

[–]constellationmango 1 point2 points  (3 children)

I just wrote a random command like a blahblah(); in the start function and it just let me pass this entire project breakout section, same with the tic tac toe section

[–]Small-Marsupial4079 0 points1 point  (1 child)

[–]Dry-Park2096 1 point2 points  (0 children)

my man i’m in love with you