-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortal.java
More file actions
43 lines (35 loc) · 1022 Bytes
/
Portal.java
File metadata and controls
43 lines (35 loc) · 1022 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
41
42
43
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class Portal extends GameObject {
Image portal;
int mapX, mapY;
public Portal(int x, int y, int mapX, int mapY){
super(0,0,0,0, x, y, null);
setBoundingRect(getX(), getY(), mapX/2, mapY/2);
openImage();
this.mapX = mapX;
this.mapY = mapY;
}
@Override
public void checkOffScreen() {
// TODO Auto-generated method stub
}
public void openImage(){
try {
URL url = getClass().getResource("images/portal.png");
portal = ImageIO.read(url);
} catch (IOException ex) {
// handle exception...
}
}
@Override
public void draw(Graphics g) {
g.drawImage(portal, this.getX() , this.getY(), mapX/2, mapY/2, null);
//g.drawRect(this.getX(), this.getY(), this.getBoundingRect().width, this.getBoundingRect().height);
}
}