-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS.java
60 lines (55 loc) · 1.51 KB
/
S.java
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Der S-Stein
*
* @author Achim Retzbach & Angelika Knittel
* @version 03/01/2016 7:53
*/
public class S extends Stein
{
@Override public void renewLocation() {
int x = posX;
int y = posY;
rot = checkRotation(rot);
if(rot == 0 || rot == 2) {
b1.setLocation(x,y-1);
b2.setLocation(x,y);
b3.setLocation(x+1,y);
b4.setLocation(x+1,y+1);
} else if(rot == 1 || rot == 3) {
b1.setLocation(x-1,y);
b2.setLocation(x,y);
b3.setLocation(x,y-1);
b4.setLocation(x+1,y-1);
}
}
protected boolean checkRot(int r)
{
int x = posX;
int y = posY;
r = checkRotation(r);
if(r == 0 || r == 2) {
if ( checkPos(x,y-1)== true && checkPos(x,y) == true && checkPos(x+1,y)== true && checkPos(x+1,y+1)== true )
{
return true;
}
else
{
return false;
}
} else if(r == 1 || r == 3) {
if( checkPos(x-1,y) == true && checkPos(x,y)== true && checkPos(x,y-1)== true && checkPos(x+1,y-1) == true )
{
return true;
}
else
{
return false;
}
}
return false;
}
public S() {
super();
}
}