-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.java
More file actions
46 lines (41 loc) · 1.08 KB
/
Block.java
File metadata and controls
46 lines (41 loc) · 1.08 KB
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
41
42
43
44
45
46
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
public class Block extends Obstacle
{
int health;
Rectangle left;
Rectangle right;
Rectangle top;
Rectangle bottom;
public Block(int x, int y, int width, int height, int s, int h, Image img)
{
super(x,y,width,height,s,h,img);
health = h;
left = new Rectangle(x,y,1,50);
right = new Rectangle(x+100,y,1,50);
top = new Rectangle(x,y,100,1);
bottom = new Rectangle(x,y+50,100,1);
}
public void move(){}
public int getHealth()
{ return health; }
public void setHealth(int h)
{ health = h; }
public String intersectsString(Rectangle other)
{
boolean b = intersects(other);
if(b==false)
return "NO";
if(other.intersects(top))
return "TOP";
if(other.intersects(bottom))
return "BOTTOM";
if(other.intersects(left))
return "LEFT";
if(other.intersects(right))
return "RIGHT";
return "INSIDE";
}
}