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

質問編集履歴

3

タイトル変更

2020/12/22 05:48

投稿

kano00
kano00

スコア3

title CHANGED
@@ -1,1 +1,1 @@
1
- JavaScript 円と形の衝突判定
1
+ JavaScript 円と形の衝突判定
body CHANGED
File without changes

2

コード修正

2020/12/22 05:48

投稿

kano00
kano00

スコア3

title CHANGED
File without changes
body CHANGED
@@ -122,7 +122,7 @@
122
122
  dy = -dy;
123
123
  }
124
124
 
125
- // 障害物1
125
+ // 障害物1
126
126
  if (
127
127
  x > obstacle.x - ballRadius &&
128
128
  x < obstacle.x + obstacleWidth + ballRadius &&
@@ -130,17 +130,17 @@
130
130
  y < obstacle.y + obstacleHeight + ballRadius
131
131
  ) {
132
132
  if (
133
- (y < obstacle.y + obstacleHeight - ballRadius &&
133
+ (y < obstacle.y + obstacleHeight + ballRadius &&
134
134
  x > obstacle.x &&
135
135
  x < obstacle.x + obstacleWidth) ||
136
- (y > obstacle.y + ballRadius &&
136
+ (y > obstacle.y - ballRadius &&
137
137
  x > obstacle.x &&
138
138
  x < obstacle.x + obstacleWidth)
139
139
  ) {
140
140
  dy = -dy;
141
141
  } else if (
142
142
  (x < obstacle.x + obstacleWidth + ballRadius &&
143
- y > obstacle.y - ballRadius &&
143
+ y > obstacle.y &&
144
144
  y < obstacle.y + obstacleHeight) ||
145
145
  (x > obstacle.x - ballRadius &&
146
146
  y > obstacle.y &&
@@ -159,17 +159,17 @@
159
159
  y < obstacle2.y + obstacle2Height + ballRadius
160
160
  ) {
161
161
  if (
162
- (y < obstacle2.y + obstacle2Height - ballRadius &&
162
+ (y < obstacle2.y + obstacle2Height + ballRadius &&
163
163
  x > obstacle2.x &&
164
164
  x < obstacle2.x + obstacle2Width) ||
165
- (y > obstacle2.y + ballRadius &&
165
+ (y > obstacle2.y - ballRadius &&
166
166
  x > obstacle2.x &&
167
167
  x < obstacle2.x + obstacle2Width)
168
168
  ) {
169
169
  dy = -dy;
170
170
  } else if (
171
171
  (x < obstacle2.x + obstacle2Width + ballRadius &&
172
- y > obstacle2.y - ballRadius &&
172
+ y > obstacle2.y &&
173
173
  y < obstacle2.y + obstacle2Height) ||
174
174
  (x > obstacle2.x - ballRadius &&
175
175
  y > obstacle2.y &&

1

HTMLコード修正

2020/12/20 01:44

投稿

kano00
kano00

スコア3

title CHANGED
File without changes
body CHANGED
@@ -17,9 +17,7 @@
17
17
  <head>
18
18
  <meta charset="UTF-8" />
19
19
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
20
- <link rel="stylesheet" href="style.css" />
21
20
  <title>Document</title>
22
- <!-- <script type="text/javascript" src="excanvas.js"></script> -->
23
21
  </head>
24
22
  <body>
25
23
  <style>