-
Notifications
You must be signed in to change notification settings - Fork 0
/
J.java
85 lines (82 loc) · 2.38 KB
/
J.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Der J Stein (länglich)
*
* @author Achim Retzbach & Angelika Knittel
* @version 03/01/2016 7:53
*/
public class J extends Stein
{
@Override public void renewLocation() {
int x = posX;
int y = posY;
rot = checkRotation(rot);
if(rot == 0) {
b1.setLocation(x,y-2);
b2.setLocation(x,y-1);
b3.setLocation(x,y);
b4.setLocation(x-1,y);
} else if(rot == 1) {
b1.setLocation(x+2,y);
b2.setLocation(x+1,y);
b3.setLocation(x,y);
b4.setLocation(x,y-1);
} else if (rot == 2) {
b1.setLocation(x,y+2);
b2.setLocation(x,y+1);
b3.setLocation(x,y);
b4.setLocation(x+1,y);
} else if(rot == 3) {
b1.setLocation(x-2,y);
b2.setLocation(x-1,y);
b3.setLocation(x,y);
b4.setLocation(x,y+1);
}
}
protected boolean checkRot(int r) {
int x = posX;
int y = posY;
r = checkRotation(r);
if(rot == 0) {
if ( checkPos(x,y-2) == true && checkPos(x,y-1) == true && checkPos(x,y) == true && checkPos(x-1,y) == true )
{
return true;
}
else
{
return false;
}
} else if(rot == 1) {
if ( checkPos(x+2,y) == true && checkPos(x+1,y) == true && checkPos(x,y) == true && checkPos(x,y-1) == true )
{
return true;
}
else
{
return false;
}
} else if (rot == 2) {
if ( checkPos(x,y+2) == true && checkPos(x,y+1) == true && checkPos(x,y) == true && checkPos(x+1,y) == true )
{
return true;
}
else
{
return false;
}
} else if(rot == 3) {
if ( checkPos(x-2,y) == true && checkPos(x-1,y) == true && checkPos(x,y) == true && checkPos(x,y+1) == true )
{
return true;
}
else
{
return false;
}
}
return false;
}
public J() {
super();
}
}