-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHole.java
More file actions
73 lines (59 loc) · 1.55 KB
/
Hole.java
File metadata and controls
73 lines (59 loc) · 1.55 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package AEIOU;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Hole extends standBoard {
// image that represents the hole position on the board
private BufferedImage image;
// current position of hole on the board
private Point pos;
//Spawn state
public boolean Spawn = false;
public boolean nowSpawn = false;
public Hole(int y) {
loadImage();
pos = new Point(0, y);
}
//Set position and spawn state
public void holeSet(Point playerPos) {
if (checkPosition[playerPos.y - 1][playerPos.x] == 0) {
this.pos.y = playerPos.y - 1;
this.pos.x = playerPos.x;
checkPosition[pos.y][pos.x] = 3;
Spawn = true;
}
}
private void loadImage() {
try {
image = ImageIO.read(new File(path + "hole.png"));
} catch (IOException exc) {
System.out.println("Error opening image file: " + exc.getMessage());
}
}
public void draw(Graphics g, ImageObserver observer) {
g.drawImage(image, pos.x * Board.TILE_SIZE, pos.y * Board.TILE_SIZE, observer);
nowSpawn = true;
}
public Point getPos() {
return pos;
}
public void setPos(Point pos) {
this.pos = pos;
}
public boolean getSpawn() {
return Spawn;
}
public void holeSpawn(boolean Spawn) {
this.Spawn = Spawn;
}
public boolean getnowSpawn() {
return nowSpawn;
}
public void nowSpawn(boolean nowSpawn) {
this.nowSpawn = nowSpawn;
}
}