回答編集履歴

1

説明を追加

2021/12/03 18:40

投稿

cx20
cx20

スコア4648

test CHANGED
@@ -4,35 +4,41 @@
4
4
 
5
5
  ```processing
6
6
 
7
- void mousePressed(){
7
+ void mousePressed() {
8
8
 
9
- noStroke();
9
+ noStroke();
10
10
 
11
- int x_pos = (int)map(mouseX,0, 400, 1, 8);
11
+ // マウス座標の 0400 1~8 に変換
12
12
 
13
- int y_pos = (int)map(mouseY,0, 400, 1, 8);
13
+ int x_pos = (int)map(mouseX, 0, 400, 1, 8);
14
14
 
15
- int x_size = 400/8;
15
+ int y_pos = (int)map(mouseY, 0, 400, 1, 8);
16
16
 
17
- int y_size = 400/8;
17
+ // 1マスのサイズを計算
18
18
 
19
- int x = x_pos * x_size - x_size/2;
19
+ int x_size = 400 / 8;
20
20
 
21
- int y = y_pos * y_size - y_size/2;
21
+ int y_size = 400 / 8;
22
22
 
23
- if(mouseButton==LEFT){
23
+ // 配置位置を計算
24
24
 
25
- fill(255);
25
+ int x = x_pos * x_size - x_size / 2;
26
26
 
27
- ellipse(x, y,35,35);
27
+ int y = y_pos * y_size - y_size / 2;
28
28
 
29
- }else if(mouseButton==RIGHT){
29
+ if (mouseButton == LEFT) {
30
30
 
31
- fill(0);
31
+ fill(255);
32
32
 
33
- ellipse(x, y,35,35);
33
+ ellipse(x, y, 35, 35);
34
34
 
35
+ } else if (mouseButton == RIGHT) {
36
+
37
+ fill(0);
38
+
39
+ ellipse(x, y, 35, 35);
40
+
35
- }
41
+ }
36
42
 
37
43
  }
38
44