-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreakOutBall.java
More file actions
40 lines (31 loc) · 960 Bytes
/
BreakOutBall.java
File metadata and controls
40 lines (31 loc) · 960 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
38
39
40
import java.awt.*;
public class BreakOutBall extends Rectangle{
BreakOutBall(int topLeftx, int topLefty, int width, int height){
super(topLeftx, topLefty, width, height);
}
public boolean overlaps (BreakOutRect r) {
//System.out.println(this.x + " " + this.y + " " + this.width + " " + this.height);
//System.out.println(r.x + " " + r.y + " " + r.width + " " + r.height);
return (this.x <= r.x + r.width) && (this.x+ this.width >= r.x) && (this.y <= r.y + r.height) && (this.y + this.height >= r.y);
}
public void moveL(){
x = x - 5;
y = y - 5;
}
public void moveT(){
x = x + 5 ;
y = y - 5 ;
}
public void moveB(){
x = x - 5 ;
y = y + 5 ;
}
public void moveR(){
x = x + 5 ;
y = y + 5 ;
}
public void draw(Graphics g) {
g.setColor(Color.PINK);
g.drawOval(x , y , width , height);
}
}