1 package erland.game.tetris;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.awt.*;
22
23 /***
24 * Represents the block:
25 * <br>0xx0
26 * <br>0xx0
27 * @author Erland Isaksson
28 */
29 class Block2 extends Block
30 {
31 /*** The color of the block */
32 protected static Color color = Color.green;
33 public Color getColor()
34 {
35 return color;
36 }
37
38 protected boolean check(BlockMatrix m, int x, int y, int rotation)
39 {
40 if(rotation>=360) {
41 rotation-=360;
42 }else if(rotation<0) {
43 rotation+=360;
44 }
45 if(!m.isUsed(x,y) && !m.isUsed(x+1,y) && !m.isUsed(x+1,y-1) && !m.isUsed(x,y-1)) {
46 return true;
47 }
48 return false;
49 }
50
51 protected void unset(BlockMatrix m, int x, int y, int rotation)
52 {
53 if(rotation>=360) {
54 rotation-=360;
55 }else if(rotation<0) {
56 rotation+=360;
57 }
58
59 m.setUnused(x,y);
60 m.setUnused(x+1,y);
61 m.setUnused(x+1,y-1);
62 m.setUnused(x,y-1);
63 }
64
65 protected void set(BlockMatrix m, int x, int y, int rotation)
66 {
67 if(rotation>=360) {
68 rotation-=360;
69 }else if(rotation<0) {
70 rotation+=360;
71 }
72
73 this.x = x;
74 this.y = y;
75 this.rotation = rotation;
76
77 m.setUsed(x,y,color);
78 m.setUsed(x+1,y,color);
79 m.setUsed(x+1,y-1,color);
80 m.setUsed(x,y-1,color);
81 }
82 }