|
125 | 125 | path.closed = true; |
126 | 126 | var thrust = new Path([-8, -4], [-14, 0], [-8, 4]); |
127 | 127 | var group = new Group(path, thrust); |
| 128 | + group.applyMatrix = true; |
128 | 129 | group.position = view.bounds.center; |
129 | 130 | return { |
130 | 131 | item: group, |
|
231 | 232 |
|
232 | 233 | // if bounding rect collision, do a line intersection test |
233 | 234 | if (crash > -1) { |
234 | | - var hit = false; |
235 | | - var pos = Rocks.children[crash].position; |
236 | | - var shipSegments = this.item.firstChild.segments; |
237 | 235 | var index = Rocks.children[crash].typeIndex; |
238 | 236 | var tempRock = Rocks.shapes[index].clone(); |
239 | 237 | tempRock.transform(Rocks.children[crash].matrix); |
240 | 238 | tempRock.remove(); |
241 | | - var rockSegments = tempRock.segments; |
242 | | - // This code should be able to be simplified alot very soon, |
243 | | - // when Paper.js implements Path#intersects(path); |
244 | | - for (var i = 0; i < rockSegments.length - 1; i++) { |
245 | | - var rockLine = new Line(rockSegments[i].point, |
246 | | - rockSegments[i + 1].point, false); |
247 | | - var shipLine = new Line(shipSegments[0].point, |
248 | | - shipSegments[1].point, false); |
249 | | - var lineHit = shipLine.intersect(rockLine); |
250 | | - if (lineHit) { |
251 | | - hit = true; |
252 | | - break; |
253 | | - } |
254 | | - } |
255 | | - if (hit) Lives.remove(); |
| 239 | + var intersections = this.item.firstChild.getIntersections(tempRock); |
| 240 | + if (intersections.length > 0) |
| 241 | + Lives.remove(); |
256 | 242 | } |
257 | 243 | } |
258 | 244 | }; |
|
0 commit comments