-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeRockStrip.java
More file actions
61 lines (51 loc) · 1.33 KB
/
Copy pathTreeRockStrip.java
File metadata and controls
61 lines (51 loc) · 1.33 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
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.awt.*;
public class TreeRockStrip extends Strip{
// 0 = no image
// 1 = tree
// 2 = rock
public TreeRockStrip(Strip prevStrip, int index){
parts = new int[SIZE];
this.index = index;
int num = prevStrip.getRandomEmptySpace();
parts[num] = 0;
parts[0] = 1;
parts[SIZE-1] = 1;
for (int i = 1; i < SIZE-1; i++){
if (i != num){
int pick = randomObject();
parts[i] = randomObject();
}
}
}
public TreeRockStrip(){
parts = new int[SIZE];
this.index = 0;
parts[0] = 1;
parts[SIZE-1] = 1;
for (int i = 1; i < SIZE-1; i++){
int pick = randomObject();
parts[i] = pick;
if (i == 6) parts[i] = 0;
}
}
public static int randomObject(){
int r = (int) (Math.random()*15);
if (r < 3){
return 1;
} else if(r < 4){
return 2;
}
return 0;
}
public int[] getObjects(){
return parts;
}
//integer value 0-19 designating x-axis location
public int getIndex(){
return index;
}
}