+ 1

How To Add Collision Detection?

I am going to make two rectangles in svg, how do I check if there is a collision?

14th Jan 2018, 6:12 PM
Someone Else
Someone Else - avatar
21 Respostas
+ 1
No
14th Jan 2018, 7:20 PM
Someone Else
Someone Else - avatar
+ 1
Yes
14th Jan 2018, 7:23 PM
Someone Else
Someone Else - avatar
+ 1
I have their size
14th Jan 2018, 7:23 PM
Someone Else
Someone Else - avatar
0
do you have their x and y positions ?
14th Jan 2018, 7:19 PM
Cain Eviatar
Cain Eviatar - avatar
0
do you have their x and y size? I should have mention it on my first comment 😂
14th Jan 2018, 7:23 PM
Cain Eviatar
Cain Eviatar - avatar
0
where (0,0) located ? top left ? middle canvas ?
14th Jan 2018, 7:36 PM
Cain Eviatar
Cain Eviatar - avatar
0
Idk I’m new to canvas
14th Jan 2018, 7:36 PM
Someone Else
Someone Else - avatar
0
add a rectangle at (0,0), where is he located ?
14th Jan 2018, 7:37 PM
Cain Eviatar
Cain Eviatar - avatar
0
Can I just show you my code and you show me how to add collision
14th Jan 2018, 7:37 PM
Someone Else
Someone Else - avatar
0
yea do it, sorry for the questions I don't program in JS...
14th Jan 2018, 7:39 PM
Cain Eviatar
Cain Eviatar - avatar
0
<svg height="200” width=“200”> <rect height="50" width="50"> <animate attributeName="x" from="0" to="300" dur="3s" repeatCount="1"/> </rect> </svg>
14th Jan 2018, 7:39 PM
Someone Else
Someone Else - avatar
0
what programming language are you using for displaying it ?
14th Jan 2018, 7:42 PM
Cain Eviatar
Cain Eviatar - avatar
0
Html
14th Jan 2018, 7:42 PM
Someone Else
Someone Else - avatar
0
the <animate> is moving the rectangle am I right ?
14th Jan 2018, 7:43 PM
Cain Eviatar
Cain Eviatar - avatar
0
Yes
14th Jan 2018, 7:43 PM
Someone Else
Someone Else - avatar
0
this is not HTML, look's like css. just wait for a moment, I'll get up to my PC to check where (0,0) is located.
14th Jan 2018, 7:44 PM
Cain Eviatar
Cain Eviatar - avatar
0
Ok, but this is html. Not css
14th Jan 2018, 7:45 PM
Someone Else
Someone Else - avatar
0
true, my bad, so as I can see the (0,0) starting from top left, which is good. let me write a little lecture.
14th Jan 2018, 7:47 PM
Cain Eviatar
Cain Eviatar - avatar
0
K
14th Jan 2018, 7:48 PM
Someone Else
Someone Else - avatar
0
wait, I came across an issue, you cannot get the rectangle size and position, because you declaring it right away, so you don't have any variable to store their position and size. you should be using js instead to store their values.
14th Jan 2018, 7:53 PM
Cain Eviatar
Cain Eviatar - avatar