createCanvas(windowWidth, windowHeight);
ball = new Ball(0, 470, 5);
for (var i = 0; i < 1; i++) {
bunker1[i] = new Bunker2(-50 + 280*i, 330, 220, 500, 60);
bunker = new PixelBunker();
for (var i = 0; i < bunker1.length; i++) {
if (bunker1[i].hitBunker(ball)) {
bunker1[i].changeColor();
bunker1[i].changeColor2();
this.display = function() {
for (var y = 0; y < 100; y++) {
for (var x = 0; x < 20; x++) {
var index = (x + y * width)*4;
pixels[index + 2200000] = 18;
pixels[index + 2200001] = 68;
pixels[index + 2200002] = 14;
pixels[index + 2200003] = 255;
function Bunker2(x, y, x1, y1, r) {
this.col = color(18, 68, 14);
this.changeColor2 = function() {
this.col = color(18, 68, 14);
this.changeColor = function() {
this.col = color(255, 0, 255);
this.hitBunker = function(ball) {
var d = dist(this.x1, this.y1, ball.x, ball.y);
if (d < this.r + ball.r) {
this.display = function() {
rect(this.x+213, this.y+152, 24, 60);
rect(this.x+303, this.y+152, 25, 60);
rect(this.x+236, this.y+128, 68, 60);
rect(this.x+221, this.y+144, 16, 8);
rect(this.x+228, this.y+136, 9, 8);
rect(this.x+303, this.y+144, 16, 8);
rect(this.x+303, this.y+136, 9, 8);
rect(this.x+236, this.y+188, 18, 7);
rect(this.x+287, this.y+188, 17, 7);
rect(this.x+236, this.y+194, 10, 9);
rect(this.x+295, this.y+194, 9, 9);
leg = createImage(25, 110);
for (i = 0; i < leg.width; i++) {
for (j = 0; j < leg.height; j++) {
leg.set(i, j, color(18, 68, 14));
this.changeColor2 = function() {
this.changeColor = function() {
this.col = color(255, 0, 255);
this.display = function() {
ellipse(this.x, this.y, this.r*2, this.r*2);
this.x = this.x + this.speed;
if (this.x >= width || this.x <= -2) {
this.speed = this.speed*-1;