+ 1

Java collusion

Now I have collusion in my 2d java game but I can't make 2 squares dont go each other. If someone has any ideas or code to give me pls don't be shy

3rd Aug 2017, 11:00 AM
Muhammed Faik Ekiciler
Muhammed Faik Ekiciler - avatar
1 Answer
0
if (x1 < x2+width2 and x1 > x2) or (x1+width > x2 and x1 < x2+width2) then you have a collision on the x axis. apply the same to the y axis. then of you have a collision on both axis it means you have an actual collision. Drawing a pic on paper might help visualize Sorry for short explanation there isnt much space, hope this helps.
11th Aug 2017, 5:52 PM
Hannes Sederholm
Hannes Sederholm - avatar