-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrick.pde
More file actions
37 lines (32 loc) · 943 Bytes
/
Copy pathbrick.pde
File metadata and controls
37 lines (32 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Brick implements Gameobject{
int width, height;
PVector position = new PVector();
Game game;
PImage brick;
Brick(Game game, int x, int y){
this.game = game;
position.x = x;
position.y = y;
width = game.brickWidth;
height = game.brickHeight;
brick = loadImage("assets/images/brick.png");
}
public float getX(){return position.x;}
public float getY(){return position.y;}
public void setX(float x){position.x = x;}
public void setY(float y){position.y = y;}
public PVector getPosition(){return this.position;}
public int getWidth(){return this.width;}
public int getHeight(){return this.height;}
void update(){
if(detectCollision(game.ball, this)){
game.ball.setSpeedY(-game.ball.getSpeedY());
this.brick = loadImage("assets/images/brick_touched.png");
//noLoop();
}
}
void display(){
imageMode(CENTER);
image(brick, position.x, position.y, this.width, this.height);
}
}