-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlocks.java
More file actions
35 lines (28 loc) · 786 Bytes
/
Blocks.java
File metadata and controls
35 lines (28 loc) · 786 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
/*
* File: Blocks.java
* ----------------------------
* This class defines a single block.
* These blocks will be used by a GCompound class, "Pairs".
*/
import acm.graphics.*;
import acm.util.RandomGenerator;
public class Blocks implements Constants {
// Each block has an image to it.
private GImage img;
// Constructor: generate a block.
// There're bottom blocks and upper blocks, and each has a different image.
// By passing a boolean value, there can be upper and bottom blocks.
public Blocks(boolean isFlip) {
GImage upperBlock = new GImage(PIPEFLIP_FILENAME);
GImage bottomBlock = new GImage(PIPE_FILENAME);
if (isFlip == true) {
img = upperBlock;
} else {
img = bottomBlock;
}
}
// Image getter.
public GImage getImg() {
return img;
}
}