0

Okay, I have searched everywhere but haven't found something specifically useful for me. Im trying to code a BreakOut Game with pure JavaScript. I've had my ups and downs, as I'm a beginner, but I managed to display and control the paddle aswell as the Ball. But I seem too stupid to build the brickwall for the ball to destroy. Im working with a few more .js files, so the Code is not stuffed into one file.

The bricks shall be initialised within the BreakOutGame.js (Main File) but the drawing of the bricks needs to be done in the file Brick.js

Here's the code in the BreakOutGame.Js

function privateInitContent(){
var bricks = [];
for (var r = 0; r < BRICK_ROWS; r++){
 for (var c = 0; c < BRICK_COLUMNS; c++){
  var brick[r][c] = new Brick(privateContext, BRICK_XPOS, BRICK_YPOS, BRICK_COLOR, BRICK_WIDTH, BRICK_HEIGHT);
   bricks[r][c].push(brick);
  }
 }
}

This seems not to work. And here's the content of the Brick.js file:

var Brick = function(context, xPos, yPos, color, width, height) {

this.context = context;

this.BrickXPos = xPos;
this.BrickYPos = yPos;
this.BrickWidth = width;
this.BrickHeight = height;

this.BrickColor = color;

}

Brick.prototype.draw = function() {

this.context.fillStyle = this.color;
 this.context.fillRect(this.BrickXPos,this.BrickYPos,this.BrickWidth,this.BrickHeight);


}

Can anyone give me an idea? I really need this :/

  • Really need to be more specific about what your exact problem within the code is. Take some time to read through [ask] and [Question checklist](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) – charlietfl Dec 18 '16 at 04:27
  • It is just not working, I mean bilding the bricks on the canvas...is there something wrong with the Array? – Jindujun Dec 18 '16 at 12:23

0 Answers0