## 2d collision with rotated pictures

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Prole
Posts: 5
Joined: Mon Oct 26, 2020 12:08 am

### 2d collision with rotated pictures

Hi everyone,
i have a big question. my problem is that i want make a collision system beetwen two rotated/angled sprites. theses sprites are both same sizes and they have rectangle form. I need it for the tank game i'm actually making and it's very urgent so i need your help.

FloatingBanana
Prole
Posts: 19
Joined: Sat Mar 02, 2019 4:57 pm
Contact:

### Re: 2d collision with rotated pictures

Take a look at the HC library.

Code: Select all

if anyMistake(self.english) then
print("Sorry, english is not my first language")
end

ivan
Party member
Posts: 1655
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: 2d collision with rotated pictures

Rotated rectangles are not simple and it's even harder if you want to have some sort of decent collision response.
I recommend using love.physics or avoid rotation altogether.
For example, you can use circles or just rotate the sprite without rotating the collision mask.

dezoitodemaio
Prole
Posts: 9
Joined: Mon Oct 26, 2020 2:02 pm

### Re: 2d collision with rotated pictures

Since rectangles are made of lines you could check line to line collision, something like https://github.com/processing/processin ... -Detection. If any line of Rectangle A intersects any line of Rectangle B then there are colliding.

ivan
Party member
Posts: 1655
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: 2d collision with rotated pictures

dezoitodemaio wrote:
Mon Oct 26, 2020 2:06 pm
Since rectangles are made of lines you could check line to line collision
Additionally one rectangle could be entirely inside another.

nikneym
Citizen
Posts: 56
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

### Re: 2d collision with rotated pictures

Mon Oct 26, 2020 12:13 am
Hi everyone,
i have a big question. my problem is that i want make a collision system beetwen two rotated/angled sprites. theses sprites are both same sizes and they have rectangle form. I need it for the tank game i'm actually making and it's very urgent so i need your help.
SAT collision detection may solve your problem. There is a tutorial of SAT implementation made by recursor but this might mean you have to change your collision detection script completely.

Prole
Posts: 5
Joined: Mon Oct 26, 2020 12:08 am

### Re: 2d collision with rotated pictures

I'm actualling trying to understand the separating axis theorem but it seems to difficult. also i know hc but i prefer sat i think i'll try to understand. do you know a french tutorial for the sat because i'm not familiar with english language

Prole
Posts: 5
Joined: Mon Oct 26, 2020 12:08 am

### Re: 2d collision with rotated pictures

dezoitodemaio wrote:
Mon Oct 26, 2020 2:06 pm
Since rectangles are made of lines you could check line to line collision, something like https://github.com/processing/processin ... -Detection. If any line of Rectangle A intersects any line of Rectangle B then there are colliding.
i'll try to implement this also

Prole
Posts: 5
Joined: Mon Oct 26, 2020 12:08 am

### Re: 2d collision with rotated pictures

the game i'm making is very similar to this one https://awesometanks2.com/ and if you can give it a look and tell me what kind of collision system they are using that would be very nice

siberian
Prole
Posts: 12
Joined: Sat Apr 06, 2019 1:42 pm

### Re: 2d collision with rotated pictures

May be will be usefull.
The main idea is to get the sum of the 2 shapes (hull). If the center of an object is inside a hull, the objects are intersecting.
In motion, check the intersection of the hull with a segment from the center of the moved object to its destination point.

The attachment rotated_boxes.love is no longer available
Attachments
rotated_boxes.love
intersection and collision of rotating boxes