Ask coding questions

← Back to all posts
Can Someone Help Me Detect Div Collision?
h
JWZ6

I'm working on this dodging game. Can someone please help me with detecting if you are dead/hit?

div collision

thanks, JWZ6

Answered by ch1ck3n [earned 5 cycles]
View Answer
Voters
JWZ6
Comments
hotnewtop
ch1ck3n

just check if the top and left properties of the two elements are in range that they are colliding

so in your case if pos_x and pos_y are same enough as pos_x_2 and pos_y_2 that means its collided

JWZ6

@ch1ck3n THANKS

ch1ck3n

@JWZ6 ping me when its finished i wanna see the finished product :P

JWZ6

@ch1ck3n u like?

ch1ck3n

@JWZ6 yes

JWZ6

@ch1ck3n hol up can i invite u

ch1ck3n

@JWZ6 wait wha

JWZ6

@ch1ck3n i get error

ch1ck3n

@JWZ6

JWZ6

@ch1ck3n yee lol