質問編集履歴

3

コードの修正

2019/12/30 12:27

投稿

aiaiaiai
aiaiaiai

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
+ ```
2
+
1
- ```//プレイヤーの設定
3
+ //プレイヤーの設定
2
4
 
3
5
  int playerx=400; //プレイヤーのx座標
4
6
 

2

コードの修正

2019/12/30 12:27

投稿

aiaiaiai
aiaiaiai

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- //プレイヤーの設定
1
+ ```//プレイヤーの設定
2
2
 
3
3
  int playerx=400; //プレイヤーのx座標
4
4
 
@@ -192,18 +192,6 @@
192
192
 
193
193
 
194
194
 
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
195
  コード
208
196
 
209
197
  ```

1

書式の改善

2019/12/30 12:11

投稿

aiaiaiai
aiaiaiai

スコア4

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ```//プレイヤーの設定
1
+ //プレイヤーの設定
2
2
 
3
3
  int playerx=400; //プレイヤーのx座標
4
4
 
@@ -34,9 +34,9 @@
34
34
 
35
35
 
36
36
 
37
- void setup(){ // 初期設定
37
+ void setup() { // 初期設定
38
-
38
+
39
- size(800,600); //800×600サイズ
39
+ size(800, 600); //800×600サイズ
40
40
 
41
41
  noStroke(); // 線なし
42
42
 
@@ -46,7 +46,7 @@
46
46
 
47
47
  b=random(255);
48
48
 
49
- for(int i=0; i<20; i++){ //繰り返す変数iは0~19まで変化する
49
+ for (int i=0; i<20; i++) { //繰り返す変数iは0~19まで変化する
50
50
 
51
51
  maruy[i]=40; //40を代入
52
52
 
@@ -58,7 +58,7 @@
58
58
 
59
59
  }
60
60
 
61
- void draw(){
61
+ void draw() {
62
62
 
63
63
  background(0); //背景の色は黒
64
64
 
@@ -70,15 +70,13 @@
70
70
 
71
71
  hitCheck();
72
72
 
73
-
74
-
75
- }
73
+ }
76
-
77
-
78
-
74
+
75
+
76
+
79
- void playersettei(){ //プレイヤーの表示
77
+ void playersettei() { //プレイヤーの表示
80
-
78
+
81
- if(mousePressed){ //マウスを押すとプレイヤーのバーが表れる
79
+ if (mousePressed) { //マウスを押すとプレイヤーのバーが表れる
82
80
 
83
81
  r=random(255); //マウスを押すたびにバーの色がランダムに変わる
84
82
 
@@ -86,112 +84,124 @@
86
84
 
87
85
  b=random(255);
88
86
 
89
- fill(r,g,b);
87
+ fill(r, g, b);
90
-
88
+
91
- rect(mouseX,playery,playerw,playerh,5);
89
+ rect(mouseX, playery, playerw, playerh, 5);
90
+
91
+ }
92
+
93
+ //if((playerx+playerw)>800){
94
+
95
+ // playerx =800;
96
+
97
+ }
98
+
99
+ void marusettei() { //物体の設定
100
+
101
+ for (int i=0; i<20; i++) { //赤い球体の物体を20個並べる繰り返しの処理
102
+
103
+ if (maruColor[i]==0) { //
104
+
105
+ fill(0, 255, 255);
106
+
107
+ } else {
108
+
109
+ fill(255, 0, 255);
110
+
111
+ }
112
+
113
+ ellipse(i*40+20, maruy[i], maruw, maruh);
114
+
115
+ }
116
+
117
+ }
118
+
119
+ void maruMove() {
120
+
121
+ for (int i=0; i<20; i++) {
122
+
123
+ if (marutaiki[i]>0) {
124
+
125
+ marutaiki[i]--;
126
+
127
+ } else {
128
+
129
+ maruy[i]+=2;
130
+
131
+ }
92
132
 
93
133
 
94
134
 
95
- }
96
-
97
- //if((playerx+playerw)>800){
98
-
99
- // playerx =800;
135
+ maruy[i] +=2;
100
-
101
- }
136
+
102
-
103
- void marusettei(){ //物体の設定
137
+ if (maruy[i]>height) {
104
-
138
+
105
- for(int i=0; i<20; i++){ //赤い球体の物体を20個並べる繰り返しの処理
139
+ maruy[i]=40;
106
-
140
+
107
- if(maruColor[i]==0){ //
141
+ maruColor[i]=int(random(2)); //物体の色の配置がランダムで変わる
108
-
109
- fill(0,255,255);
142
+
110
-
111
- }else{
112
-
113
- fill(255,0,255);
143
+ marutaiki[i]=int(random(60, 240));
114
144
 
115
145
  }
116
146
 
117
- ellipse(i*40+20,maruy[i],maruw,maruh);
118
-
119
- }
147
+ }
148
+
149
+
150
+
151
+ void hitCheck() {
152
+
153
+ for (int i=0; i<20; i++) {
154
+
155
+ marux=i*40;
156
+
157
+ if (player.isCollision(maru[i])) {
158
+
159
+ maru[i].dead();
160
+
161
+
162
+
163
+ if (player.getColor()==maru[i].getColor()) {
164
+
165
+ score +=3;
166
+
167
+ } else {
168
+
169
+ score -=5;
170
+
171
+ }
172
+
173
+ }
174
+
175
+
176
+
177
+ //スコア
178
+
179
+ fill(255);
180
+
181
+ textSize(20);
182
+
183
+ text("SCORE", 10, 30);
184
+
185
+ text(score, 100, 30);
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
120
200
 
121
201
 
122
202
 
123
- }
124
-
125
- void maruMove(){
126
-
127
- for(int i=0; i<20; i++){
128
-
129
- if(marutaiki[i]>0){
130
-
131
- marutaiki[i]--;
132
-
133
- }else{
134
-
135
- maruy[i]+=2;
136
-
137
- }
138
-
139
- maruy[i] +=2;
140
-
141
- if(maruy[i]>height){
142
-
143
- maruy[i]=40;
144
-
145
- maruColor[i]=int(random(2)); //物体の色の配置がランダムで変わる
146
-
147
- marutaiki[i]=int(random(60,240));
148
-
149
- }
150
-
151
- }
152
-
153
- void hitCheck(){
154
-
155
- for(int i=0; i<20; i++){
156
-
157
- marux=i*40;20;
158
-
159
- if(player.isCollision(maru[i])){
160
-
161
- maru[i].dead();
162
-
163
203
 
164
204
 
165
- if(player.getColor()==maru[i].getColor()){
166
-
167
- score +=3;
168
-
169
- }else{
170
-
171
- score -=5;
172
-
173
- }
174
-
175
-
176
-
177
- //スコア
178
-
179
- fill(255);
180
-
181
- textSize(20);
182
-
183
- text("SCORE",10,30);
184
-
185
- text(score,100,30);
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
205
 
196
206
 
197
207
  コード