質問編集履歴

1

誤字

2021/04/29 08:19

投稿

pm_colenite
pm_colenite

スコア0

test CHANGED
File without changes
test CHANGED
@@ -24,13 +24,207 @@
24
24
 
25
25
  ### 該当のソースコード
26
26
 
27
-
27
+ void setup() {
28
+
29
+
30
+
31
+ size(400, 300);// enlarge window
32
+
33
+ }
34
+
35
+
36
+
37
+ float x = 70; //declare variable
38
+
39
+ float y = 70; //declare variable
40
+
41
+ float dx = 1; //declare variable
42
+
43
+ float dy = 2; //declare variable
44
+
45
+
46
+
47
+
48
+
49
+ int count = 0; // declare variable for counting hits
50
+
51
+ int misscount = 0;
52
+
53
+
54
+
55
+
56
+
57
+ void draw() {
58
+
59
+ if (x+6 > width) { // at the right end change direction ボールが左右の壁に当たった時の判定
60
+
61
+ dx = -1;
62
+
63
+ } else if (x-3 <= 0) { // at the right end change direction ボールが左右の壁に当たった時の判定
64
+
65
+ dx = 1;
66
+
67
+ }
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ if (y > height) { // at the floor change direction ボールが上下に当たった時の判定
80
+
81
+ dy = -2;
82
+
83
+ } else if ( y-3 <= 0) { // at the bottom change direction ボールが上下に当たった時の判定
84
+
85
+ dy = 2;//
86
+
87
+ }
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ x = x + dx; // move x coordinate and add dx to x at each step 
98
+
99
+ y = y + dy; // move y coordinate and add dy to y at each step
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ background(0, 0, 106);// draw the background
116
+
117
+ for (int j = 0; j < 4; j++) {
118
+
119
+ for (int i = 0; i<11; i++) {
120
+
121
+ if (y > height) { // at the floor change direction ボールが上下に当たった時の判定
122
+
123
+ dy = -2;
124
+
125
+ fill(255);
126
+
127
+ }
128
+
129
+ rect(40*i, 15*j, 39, 14);
130
+
131
+ if (y == 60 && 400 <= x ) {
132
+
133
+ dy = 2;
134
+
135
+
136
+
137
+ }
138
+
139
+
140
+
141
+
142
+
143
+ }
144
+
145
+ rect(x, y, 3, 3); // draw a boll
146
+
147
+ fill(153, 255, 255);
148
+
149
+ rect(mouseX, 250, 50, 3);
150
+
151
+ fill(255, 255, 255);
152
+
153
+ if (mouseX >= 350) {
154
+
155
+ mouseX = 349; //show a Pad
156
+
157
+ }
158
+
159
+ if (misscount == 0) {
160
+
161
+ rect(350, 280, 5, 5);
162
+
163
+ rect(360, 280, 5, 5);
164
+
165
+ text(count, 10, 280); // show count
166
+
167
+ }
168
+
169
+ if (misscount == 1) {
170
+
171
+ rect(350, 280, 5, 5);
172
+
173
+ text(count, 10, 280); // show count
174
+
175
+ }
176
+
177
+ if (misscount == 2) {
178
+
179
+ text(count, 10, 280); // show count
180
+
181
+ }
182
+
183
+ if ( y >= 250) {
184
+
185
+ if (x >= mouseX && x <= mouseX + 50) {
186
+
187
+ dy = -2;
188
+
189
+ count = count + 1; // increment count
190
+
191
+ } else {
192
+
193
+ count = 0; //reset counter
194
+
195
+ x = 0; //move to initial position
196
+
197
+ y = 0; //move to initial position
198
+
199
+ dx = 1; //change to be initial velocity
200
+
201
+ dy = 2; //change to be initial velocity
202
+
203
+ misscount = misscount+1;
204
+
205
+ }
206
+
207
+ }
208
+
209
+ if ( misscount >=3) {
210
+
211
+ textSize(60);
212
+
213
+ text("GAMEOVER", 30, 150);
214
+
215
+ x = 450;
216
+
217
+ y = 450;
218
+
219
+ }
220
+
221
+ }
222
+
223
+ }
28
224
 
29
225
  ```ここに言語名を入力
30
226
 
31
- processing
227
+ ```processing
32
-
33
- ```
34
228
 
35
229
 
36
230