-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlapTester.cs
56 lines (40 loc) · 1.39 KB
/
overlapTester.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace ActionGame
{
class overlapTester
{
public bool overlapRectangles(Rectangle r1, Rectangle r2)
{
if (r1.X < r2.X + r2.Width && r1.X + r1.Width > r2.X && r1.Y + r1.Height > r2.Y && r1.Y < r2.Y + r2.Height) return true;
return false;
}
public int overlapRectanglesEX(Rectangle r1,Rectangle r2)
{
if (r1.X < r2.X + r2.Width && r1.X + r1.Width > r2.X && r1.Y + r1.Height > r2.Y && r1.Y < r2.Y + r2.Height) {
int a1 = r2.X + r2.Width - r1.X;
int a2 = r1.X + r1.Width - r2.X;
int a3 = r2.Y + r2.Height - r1.Y;
int a4 = r1.Y + r1.Height - r2.Y;
int flag = 0;
if (a1 < a2) { flag = 1; }
else { flag = 2; }
if (a3 < a4)
{
if (flag == 1 && a1 < a3) { return 1; }
else { return 3; }
} else
if (flag == 2 && a2 < a4) { return 2; }
else { return 4; }
}
else { return 0; }
}
}
}