+ 1
How To Add Collision Detection?
I am going to make two rectangles in svg, how do I check if there is a collision?
21 Respostas
+ 1
No
+ 1
Yes
+ 1
I have their size
0
do you have their x and y positions ?
0
do you have their x and y size? I should have mention it on my first comment 😂
0
where (0,0) located ?
top left ?
middle canvas ?
0
Idk I’m new to canvas
0
add a rectangle at (0,0), where is he located ?
0
Can I just show you my code and you show me how to add collision
0
yea do it, sorry for the questions I don't program in JS...
0
<svg height="200” width=“200”>
<rect height="50" width="50">
<animate attributeName="x" from="0" to="300" dur="3s" repeatCount="1"/>
</rect>
</svg>
0
what programming language are you using for displaying it ?
0
Html
0
the <animate> is moving the rectangle am I right ?
0
Yes
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.
0
Ok, but this is html. Not css
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.
0
K
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.