-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutline.java
More file actions
56 lines (51 loc) · 1.54 KB
/
Copy pathOutline.java
File metadata and controls
56 lines (51 loc) · 1.54 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Outline here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Outline extends Actor
{
private Tetromino parent;
public Outline(Tetromino initParent) {
String color;
switch (initParent.getType()) {
// O
case 0: color = "yellow";
break;
// I
case 1: color = "lightblue";
break;
// Z
case 2: color = "red";
break;
// S
case 3: color = "green";
break;
// T
case 4: color = "purple";
break;
// L
case 5: color = "orange";
break;
// J
case 6: color = "darkblue";
break;
default: color = "red";
break;
}
setImage(color + ".png");
getImage().setTransparency(50);
parent = initParent;
}
public void fall() {
setLocation(getX(), getY()+1);
if (getIntersectingObjects(Border.class).size() > 0 && !getIntersectingObjects(Border.class).get(0).isPassable()) {
parent.solidifyOutlines();
}
if (getIntersectingObjects(Tile.class).size() > 0 && getIntersectingObjects(Tile.class).get(0).isSolid()) {
parent.solidifyOutlines();
}
}
}