質問編集履歴

1

マークダウンをした

2016/10/16 05:22

投稿

udooon
udooon

スコア12

test CHANGED
File without changes
test CHANGED
@@ -4,115 +4,117 @@
4
4
 
5
5
  ソースコードは以下の通りです。
6
6
 
7
- private boolean canMove(Rect movedRect) {
7
+ private boolean canMove(Rect movedRect) {
8
8
 
9
9
 
10
10
 
11
- int horizontalBlock = movedRect.centerX() / blockSize;
11
+ int horizontalBlock = movedRect.centerX() / blockSize;
12
-
13
- int verticalBlock = movedRect.centerY() / blockSize;
14
12
 
15
13
 
16
14
 
17
- if (placeHorizontalBlock != horizontalBlock
18
-
19
- || placeVerticalBlock != verticalBlock) {
20
-
21
- setTargetBlock(verticalBlock, horizontalBlock);
22
-
23
- placeHorizontalBlock = horizontalBlock;
24
-
25
- placeVerticalBlock = verticalBlock;
15
+ int verticalBlock = movedRect.centerY() / blockSize;
26
-
27
- }
28
16
 
29
17
 
30
18
 
31
- int yLength = targetBlock.length;
19
+ > if (placeHorizontalBlock != horizontalBlock
32
20
 
21
+ > || placeVerticalBlock != verticalBlock) {
22
+
23
+ setTargetBlock(verticalBlock, horizontalBlock);
24
+
33
- for (int y = 0; y < yLength; y++) {
25
+ placeHorizontalBlock = horizontalBlock;
26
+
27
+ placeVerticalBlock = verticalBlock;
28
+
29
+ }
34
30
 
35
31
 
36
32
 
37
- int xLength = targetBlock[0].length;
33
+ int yLength = targetBlock.length;
38
-
39
- for (int x = 0; x < xLength; x++) {
40
-
41
- int clearCounter =0; //最初は0 ・・・(1)
42
34
 
43
35
 
44
36
 
45
- Block block = targetBlock[y][x];
37
+ > for (int y = 0; y < yLength; y++) {
46
38
 
47
- if (block == null) {
39
+ > for (int x = 0; x < xLength; x++) {
48
-
49
- continue;
50
-
51
- }
52
-
53
- if (block.type == Block.TYPE_WALL && Rect.intersects(block.rect, movedRect)) {
54
-
55
- return false;
56
40
 
57
41
 
58
42
 
59
- //ゴールと重なったらonGoalを呼び出す ・・・(2)
43
+ >> int clearCounter =0; //最初は0 ・・・(1)
60
-
61
- } else if (block.type == Block.TYPE_GOAL
62
-
63
- && block.rect.contains(movedRect.centerX(), movedRect.centerY())) {
64
44
 
65
45
 
66
46
 
67
- clearCounter += 1; //呼び出される度にclearCounterに1足したい
47
+ >> Block block = targetBlock[y][x];
68
48
 
69
49
 
70
50
 
71
- if ( clearCounter < 3) { //3回未満ならonGoalを呼びたい
51
+ >> if (block == null) {
72
52
 
53
+ continue;
73
54
 
74
-
75
- eventCallback.onGoal();
76
-
77
- return true;
78
-
79
-
80
-
81
- } else { //3回以上ならonChangeを呼びたい
82
-
83
- eventCallback.onChange();
84
-
85
- return true;
86
-
87
- }
55
+ }
88
-
89
-
90
-
91
- //穴に重なったら穴を呼び出す
92
-
93
- } else if (block.type == Block.TYPE_HOLE
94
-
95
- && block.rect.contains(movedRect.centerX(), movedRect.centerY()) ) {
96
56
 
97
57
 
98
58
 
99
59
 
100
60
 
101
- eventCallback.onHole();
61
+ >> if (block.type == Block.TYPE_WALL && Rect.intersects(block.rect, movedRect)) {
102
62
 
103
- return false;
63
+ return false;
64
+
65
+ }
104
66
 
105
67
 
106
68
 
107
- }
108
69
 
109
- }
110
70
 
111
- }
71
+ >> //ゴールと重なったらonGoalを呼び出す ・・・(2)
112
72
 
113
- return true;
73
+ else if (block.type == Block.TYPE_GOAL
114
74
 
75
+ && block.rect.contains(movedRect.centerX(), movedRect.centerY())) {
76
+
77
+
78
+
79
+ >> clearCounter += 1; //呼び出される度にclearCounterに1足したい
80
+
81
+
82
+
83
+ >> if ( clearCounter < 3) { //3回未満ならonGoalを呼びたい
84
+
85
+ eventCallback.onGoal();
86
+
87
+ return true;
88
+
89
+
90
+
91
+ >> } else { //3回以上ならonChangeを呼びたい
92
+
93
+ eventCallback.onChange();
94
+
95
+ return true;
96
+
115
- }
97
+ }
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ > }
106
+
107
+ > }
108
+
109
+
110
+
111
+ }
112
+
113
+ return true;
114
+
115
+
116
+
117
+ }
116
118
 
117
119
 
118
120