-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.pde
More file actions
36 lines (32 loc) · 828 Bytes
/
Block.pde
File metadata and controls
36 lines (32 loc) · 828 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
class Block extends AABB {
private int hp;
Block(float x, float y, float width, float height, int hp) {
super(x, y, width, height);
this.hp = hp;
}
void show() {
if (this.hp <= 0) return;
text(this.hp, this.x, this.y); // 消すために必要なhitの個数の表示
rect(this.x, this.y, this.width, this.height); // ブロックの形の表示
}
void damage() {
this.hp -= 1;
}
void applyBallBounceOrNot(Ball ball) {
if (this.hp <= 0) return;
int ret = ball.willOverlapByPositionDifferential(this);
if (ret > 0) {
if (ret == 1) {
ball.bounceX();
} else if (ret == 2) {
ball.bounceY();
this.damage();
} else if (ret == 3) {
ball.bounceX();
ball.bounceY();
this.damage();
}
return;
}
}
}