-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipe.java
More file actions
66 lines (53 loc) · 1.78 KB
/
Copy pathPipe.java
File metadata and controls
66 lines (53 loc) · 1.78 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
package Evolution;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
/**
*This class models a Pipe, and is contained within the Game class.
*/
public class Pipe {
private ImageView _toppipe;
private ImageView _bottompipe;
/*
* This method constructs a pipe which is made out of two imageview nodes (one of the top pipe and one of the bottom pipe).
*/
public Pipe() {
Image toppipe = new Image (this.getClass().getResourceAsStream("toppipe.png"));
_toppipe= new ImageView();
_toppipe.setImage(toppipe);
_toppipe.setFitHeight(Constants.PIPE_HEIGHT);
_toppipe.setFitWidth(Constants.PIPE_WIDTH);
_toppipe.setY(Constants.TOPPIPE_Y);
Image bottompipe= new Image (this.getClass().getResourceAsStream("bottompipe.png"));
_bottompipe= new ImageView();
_bottompipe.setImage(bottompipe);
_bottompipe.setFitHeight(Constants.PIPE_HEIGHT);
_bottompipe.setFitWidth(Constants.PIPE_WIDTH);
_bottompipe.setY(Constants.BOTTOMPIPE_Y);
}
/*
* This method returns the rectangle that makes up the top pipe, and is called in the game class to get the location of the top pipe
*/
public ImageView gettopPipe() {
return _toppipe;
}
/*
* This method returns the rectangle that makes up the bottom pipe, and is called in the game class to get the location of the bottom pipe
*/
public ImageView getbottomPipe() {
return _bottompipe;
}
/*
* This method sets the Y location of the top pipe and the bottom pipe to a certain y, and is called in the game class.
*/
public void setYLoc(double y) {
_toppipe.setY(y);
_bottompipe.setY(y);
}
/*
* This method sets the Y location of the top pipe and the bottom pipe to a certain y, and is called in the game class.
*/
public void setXLoc(double x) {
_toppipe.setX(x);
_bottompipe.setY(x);
}
}