i want to make special brickgame
It is characteristic that the brick line is continuously generated and comes down from the top.
i can make normal brickgame but its very hard to me
I want you to give me answers or hints.
plz ㅜㅜ help me
int x=20, y=20, xd=8, yd=9;
int padx, padw=400;
PImage img;
int [ ] [ ] bricks = new int [2][10];
int i, j;
float d, down;
int score;
Boolean dead, play;
void setup() {
size(500, 700);
img = loadImage("cheonji.jpg");
newGame();
}
void draw() {
if (play==true) {
image(img, 0, 0, 500, 700);
noStroke();
fill(255, 0, 0);
ellipse(x, y, 10, 10);
x=x+xd;
y=y+yd;
if (x < 5 || x > width-5) xd=xd*-1;
if (y < 5) yd=yd*-1;
if (padx < x && x < padx+padw &&
y+5 > height-20)
{
if (keyPressed && keyCode==LEFT) xd -=2;
else if (keyPressed && keyCode==RIGHT) xd+=2;
yd=yd*-1;
}
stroke(0, 0, 255);
line(padx, height-20, padx+padw, height-20);
if (keyPressed && keyCode==LEFT && padx>=0) padx-=6;
if (keyPressed && keyCode==RIGHT && padx<=width-padw)
padx+=6;
fill(255, 0, 0);
;
textSize(20);
text(score, 50, 50);
if (y>height) {
text("dead", width/2-5, height/2);
dead = true;
play=false;
}
d+=0.1;
for (i=0; i<2; i++)
for ( j=0; j<10; j++) {
strokeWeight(5);
if (bricks[i] [ j] == 1) fill(255);
else {
fill (0, 0, 0, 0);
strokeWeight(0);
}
down=-(i*20)+20+d;
rect (j*50, down, 50, 20);
}
if (y<down) {
if (bricks [y/20] [x/50]==1) {
bricks [y/20] [x/50] = 0;
yd=yd*-1;
score++;
}
}
fill(255, 0, 0);
;
textSize(20);
text(score, 50, 50);
}
if (dead==true) {
text("Dead", 30, height/20);
if (mousePressed == true)
newGame();
}
}
void newGame() {
int i, j;
x = width / 2;
y = height / 2;
xd= 8;
yd= 9;
padx = width /2;
padw = 500;
dead = false;
play = true;
score = 0;
for (i=0; i<2; i++)
for ( j=0; j<10; j++) {
bricks[i] [j] = 1;
}
fill (100);
strokeWeight (2);
stroke (255);
}