回答編集履歴

1

コードの論理を変更

2018/03/17 01:26

投稿

KSwordOfHaste
KSwordOfHaste

スコア18394

test CHANGED
@@ -50,63 +50,69 @@
50
50
 
51
51
  function draw() {
52
52
 
53
- // 背景をクリア
53
+ if (stage <= 3) {
54
54
 
55
- fill(220)
55
+ // 背景をクリア
56
56
 
57
- noStroke()
57
+ fill(220)
58
58
 
59
- rect(0, 0, 400, 400)
59
+ noStroke()
60
60
 
61
- // 三角形を描画
62
-
63
- stroke(0)
64
-
65
- triangle(50, 250, 350, 250, x, y)
61
+ rect(0, 0, 400, 400)
66
62
 
67
63
 
68
64
 
69
- // 頂点座標段階に応じて移動
65
+ // 三角形描画
70
66
 
71
- switch (stage) {
67
+ stroke(0)
72
68
 
73
- case 1:
69
+ triangle(50, 250, 350, 250, x, y)
74
70
 
75
- if (y >= 100) {
76
71
 
77
- y--
78
72
 
79
- break
73
+ // 頂点座標を段階に応じて移動
80
74
 
81
- }
75
+ switch (stage) {
82
76
 
83
- stage++
77
+ case 1:
84
78
 
85
- case 2:
79
+ if (y >= 100) {
86
80
 
87
- if (x <= 200) {
81
+ y--
88
82
 
89
- x++
83
+ break
90
84
 
91
- break
85
+ }
92
86
 
93
- }
87
+ stage++
94
88
 
95
- stage++
89
+ case 2:
96
90
 
97
- case 3:
91
+ if (x <= 200) {
98
92
 
99
- if (x >= 50 && y <= 250) {
93
+ x++
100
94
 
101
- x--
95
+ break
102
96
 
103
- y++
97
+ }
104
98
 
105
- break
99
+ stage++
106
100
 
107
- }
101
+ case 3:
108
102
 
103
+ if (x >= 50 && y <= 250) {
104
+
105
+ x--
106
+
107
+ y++
108
+
109
+ break
110
+
111
+ }
112
+
109
- stage++
113
+ stage++
114
+
115
+ }
110
116
 
111
117
  }
112
118
 
@@ -142,11 +148,17 @@
142
148
 
143
149
  function draw() {
144
150
 
145
- ...
151
+ if (stage < operations.length) {
146
152
 
147
- if (stage < operations.length && !operations[stage]()) {
153
+ // 描画など
148
154
 
155
+ ...
156
+
157
+ if (!operations[stage]()) {
158
+
149
- stage++
159
+ stage++
160
+
161
+ }
150
162
 
151
163
  }
152
164