BlueGit

timfa frameworkv3

collision fix

timfa wsadhelios · pushed by timfa

Authored 2022-10-20 · 4 years ago

Hash
087f003743eba8b9342a0fdc8cfd4a60339efab9
Parent
80842981
1 file changed +8 −8
framework/engine/objectComponents/collider.js +8 −8
@@ -104,17 +104,17 @@ class Collider
104 104 //CHECK FROM OBJ PERSPECTIVE
105 105 var points =
106 106 [
107 [this.gameObject.transform.position.x - hw, this.gameObject.transform.position.y - hh], // topleft
108 [this.gameObject.transform.position.x + hw, this.gameObject.transform.position.y - hh], // topright
109 [this.gameObject.transform.position.x - hw, this.gameObject.transform.position.y + hh], // bottomleft
110 [this.gameObject.transform.position.x + hw, this.gameObject.transform.position.y + hh] // bottomright
107 this.gameObject.transform.position.x - hw,
108 this.gameObject.transform.position.x + hw,
109 this.gameObject.transform.position.y - hh,
110 this.gameObject.transform.position.y + hh
111 111 ];
112 112
113 if (points[0][0] >= o2.transform.position.x - ohw && points[0][0] <= o2.transform.position.x + ohw ||
114 points[0][1] >= o2.transform.position.x - ohw && points[0][0] <= o2.transform.position.x + ohw)
113 if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||
114 points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
115 115 {
116 if (points[2][0] > o2.transform.position.y - ohh && points[0][0] <= o2.transform.position.x + ohh ||
117 points[2][1] >= o2.transform.position.y - ohh && points[2][0] <= o2.transform.position.y + ohh)
116 if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||
117 points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
118 118 {
119 119 hit = true;
120 120 }
@@ -104,17 +104,17 @@ class Collider
104 //CHECK FROM OBJ PERSPECTIVE
104 //CHECK FROM OBJ PERSPECTIVE
105 var points =
105 var points =
106 [
106 [
107 [this.gameObject.transform.position.x - hw, this.gameObject.transform.position.y - hh], // topleft
107 this.gameObject.transform.position.x - hw,
108 [this.gameObject.transform.position.x + hw, this.gameObject.transform.position.y - hh], // topright
108 this.gameObject.transform.position.x + hw,
109 [this.gameObject.transform.position.x - hw, this.gameObject.transform.position.y + hh], // bottomleft
109 this.gameObject.transform.position.y - hh,
110 [this.gameObject.transform.position.x + hw, this.gameObject.transform.position.y + hh] // bottomright
110 this.gameObject.transform.position.y + hh
111 ];
111 ];
112
112
113 if (points[0][0] >= o2.transform.position.x - ohw && points[0][0] <= o2.transform.position.x + ohw ||
113 if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||
114 points[0][1] >= o2.transform.position.x - ohw && points[0][0] <= o2.transform.position.x + ohw)
114 points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
115 {
115 {
116 if (points[2][0] > o2.transform.position.y - ohh && points[0][0] <= o2.transform.position.x + ohh ||
116 if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||
117 points[2][1] >= o2.transform.position.y - ohh && points[2][0] <= o2.transform.position.y + ohh)
117 points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
118 {
118 {
119 hit = true;
119 hit = true;
120 }
120 }