teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

誤字

2021/04/29 08:19

投稿

pm_colenite
pm_colenite

スコア0

title CHANGED
File without changes
body CHANGED
@@ -11,10 +11,107 @@
11
11
  ```なし
12
12
 
13
13
  ### 該当のソースコード
14
+ void setup() {
14
15
 
16
+ size(400, 300);// enlarge window
17
+ }
18
+
19
+ float x = 70; //declare variable
20
+ float y = 70; //declare variable
21
+ float dx = 1; //declare variable
22
+ float dy = 2; //declare variable
23
+
24
+
25
+ int count = 0; // declare variable for counting hits
26
+ int misscount = 0;
27
+
28
+
29
+ void draw() {
30
+ if (x+6 > width) { // at the right end change direction ボールが左右の壁に当たった時の判定
31
+ dx = -1;
32
+ } else if (x-3 <= 0) { // at the right end change direction ボールが左右の壁に当たった時の判定
33
+ dx = 1;
34
+ }
35
+
36
+
37
+
38
+
39
+
40
+ if (y > height) { // at the floor change direction ボールが上下に当たった時の判定
41
+ dy = -2;
42
+ } else if ( y-3 <= 0) { // at the bottom change direction ボールが上下に当たった時の判定
43
+ dy = 2;//
44
+ }
45
+
46
+
47
+
48
+
49
+ x = x + dx; // move x coordinate and add dx to x at each step 
50
+ y = y + dy; // move y coordinate and add dy to y at each step
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ background(0, 0, 106);// draw the background
59
+ for (int j = 0; j < 4; j++) {
60
+ for (int i = 0; i<11; i++) {
61
+ if (y > height) { // at the floor change direction ボールが上下に当たった時の判定
62
+ dy = -2;
63
+ fill(255);
64
+ }
65
+ rect(40*i, 15*j, 39, 14);
66
+ if (y == 60 && 400 <= x ) {
67
+ dy = 2;
68
+
69
+ }
70
+
71
+
72
+ }
73
+ rect(x, y, 3, 3); // draw a boll
74
+ fill(153, 255, 255);
75
+ rect(mouseX, 250, 50, 3);
76
+ fill(255, 255, 255);
77
+ if (mouseX >= 350) {
78
+ mouseX = 349; //show a Pad
79
+ }
80
+ if (misscount == 0) {
81
+ rect(350, 280, 5, 5);
82
+ rect(360, 280, 5, 5);
83
+ text(count, 10, 280); // show count
84
+ }
85
+ if (misscount == 1) {
86
+ rect(350, 280, 5, 5);
87
+ text(count, 10, 280); // show count
88
+ }
89
+ if (misscount == 2) {
90
+ text(count, 10, 280); // show count
91
+ }
92
+ if ( y >= 250) {
93
+ if (x >= mouseX && x <= mouseX + 50) {
94
+ dy = -2;
95
+ count = count + 1; // increment count
96
+ } else {
97
+ count = 0; //reset counter
98
+ x = 0; //move to initial position
99
+ y = 0; //move to initial position
100
+ dx = 1; //change to be initial velocity
101
+ dy = 2; //change to be initial velocity
102
+ misscount = misscount+1;
103
+ }
104
+ }
105
+ if ( misscount >=3) {
106
+ textSize(60);
107
+ text("GAMEOVER", 30, 150);
108
+ x = 450;
109
+ y = 450;
110
+ }
111
+ }
112
+ }
15
113
  ```ここに言語名を入力
16
- processing
114
+ ```processing
17
- ```
18
115
 
19
116
  ### 試したこと
20
117
  ゴリ押しでなんとかなると思い、長方形を上書きしてやろうと思ったんですけど、