├── .gitignore ├── CollisionDiagrams.ai ├── Website ├── images │ ├── challenge.jpg │ ├── license.jpg │ ├── line-rect.jpg │ ├── rect-rect.jpg │ ├── tri-point.jpg │ ├── line-point.jpg │ ├── poly-point.jpg │ ├── bounding-box.jpg │ ├── line-of-sight.jpg │ ├── point-circle.jpg │ ├── bounding-circle.jpg │ ├── social-thumbnail.jpg │ ├── rect-bounding-box.jpg │ ├── table-of-contents.jpg │ └── where-are-other-triangle-examples.jpg ├── rect-rect_test_edges.php ├── section_5_challenges.php ├── where_are_the_other_triangle_examples.php ├── section_4_challenges.php ├── includes │ └── footer.php ├── section_2_challenges.php ├── section_1_challenges.php ├── section_3_challenges.php ├── js │ └── smartquotes.min.js ├── license.php ├── thanks.php ├── table_of_contents.php ├── point-point.php ├── circle-circle.php ├── index.php ├── tri-point.php ├── line-line.php ├── point-rect.php ├── circle-rect.php ├── line-point.php ├── rect-rect.php ├── what_you_should_already_know.php ├── point-circle.php ├── line-rect.php ├── poly-line.php ├── poly-rect.php ├── poly-poly.php ├── object_oriented_collision.php ├── line-circle.php ├── poly-point.php └── css │ └── stylesheet.css ├── CodeExamples ├── ObjectOrientedCollision │ ├── Circle.pde │ ├── Rectangle.pde │ ├── CircleRectCollision.pde │ ├── ObjectOrientedCollision.pde │ └── web-export │ │ └── ObjectOrientedCollision.pde ├── Introduction │ ├── Circle.pde │ ├── Rectangle.pde │ ├── Line.pde │ ├── Introduction.pde │ └── CollisionFunctions.pde ├── PointPoint │ ├── PointPoint.pde │ └── web-export │ │ └── PointPoint.pde ├── CircleCircle │ ├── web-export │ │ └── CircleCircle.pde │ └── CircleCircle.pde ├── PointRect │ ├── PointRect.pde │ └── web-export │ │ └── PointRect.pde ├── RectRect │ ├── RectRect.pde │ └── web-export │ │ └── RectRect.pde ├── PointCircle │ ├── PointCircle.pde │ └── web-export │ │ └── PointCircle.pde ├── TriPoint │ ├── TriPoint.pde │ └── web-export │ │ └── TriPoint.pde ├── LinePoint │ ├── LinePoint.pde │ └── web-export │ │ └── LinePoint.pde ├── CircleRect │ ├── CircleRect.pde │ └── web-export │ │ └── CircleRect.pde ├── LineLine │ ├── web-export │ │ └── LineLine.pde │ └── LineLine.pde ├── PolyPoint │ ├── PolyPoint.pde │ └── web-export │ │ └── PolyPoint.pde ├── LineRect │ ├── LineRect.pde │ └── web-export │ │ └── LineRect.pde ├── PolyLine │ ├── PolyLine.pde │ └── web-export │ │ └── PolyLine.pde ├── LineCircle │ ├── LineCircle.pde │ └── web-export │ │ └── LineCircle.pde ├── PolyRect │ ├── PolyRect.pde │ └── web-export │ │ └── PolyRect.pde ├── PolyPoly │ ├── PolyPoly.pde │ └── web-export │ │ └── PolyPoly.pde └── PolyCircle │ ├── PolyCircle.pde │ └── web-export │ └── PolyCircle.pde └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ToDo.txt 2 | markdown.pl 3 | _OldVersions/ 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /CollisionDiagrams.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/CollisionDiagrams.ai -------------------------------------------------------------------------------- /Website/images/challenge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/challenge.jpg -------------------------------------------------------------------------------- /Website/images/license.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/license.jpg -------------------------------------------------------------------------------- /Website/images/line-rect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/line-rect.jpg -------------------------------------------------------------------------------- /Website/images/rect-rect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/rect-rect.jpg -------------------------------------------------------------------------------- /Website/images/tri-point.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/tri-point.jpg -------------------------------------------------------------------------------- /Website/images/line-point.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/line-point.jpg -------------------------------------------------------------------------------- /Website/images/poly-point.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/poly-point.jpg -------------------------------------------------------------------------------- /Website/images/bounding-box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/bounding-box.jpg -------------------------------------------------------------------------------- /Website/images/line-of-sight.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/line-of-sight.jpg -------------------------------------------------------------------------------- /Website/images/point-circle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/point-circle.jpg -------------------------------------------------------------------------------- /Website/images/bounding-circle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/bounding-circle.jpg -------------------------------------------------------------------------------- /Website/images/social-thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/social-thumbnail.jpg -------------------------------------------------------------------------------- /Website/images/rect-bounding-box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/rect-bounding-box.jpg -------------------------------------------------------------------------------- /Website/images/table-of-contents.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/table-of-contents.jpg -------------------------------------------------------------------------------- /Website/images/where-are-other-triangle-examples.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffThompson/CollisionDetection/HEAD/Website/images/where-are-other-triangle-examples.jpg -------------------------------------------------------------------------------- /Website/rect-rect_test_edges.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | Try these challenge prompts to modify the code we've written:
10 | 11 |
You might be wondering where all the other triangle collision examples are. The answer: we've already made them! The smallest number of sides a polygon can have is three, so all the polygon code will work for triangles too.
8 | 9 |However, since our polygon code is meant to work with PVectors, you will need to define your triangles using three PVector objects, or modify the collision functions.
10 | 11 | 12 | -------------------------------------------------------------------------------- /CodeExamples/ObjectOrientedCollision/Rectangle.pde: -------------------------------------------------------------------------------- 1 | 2 | class Rectangle { 3 | float x, y; // position 4 | float w, h; // size 5 | boolean hit = false; // is it hit? 6 | 7 | Rectangle (float _x, float _y, float _w, float _h) { 8 | x = _x; 9 | y = _y; 10 | w = _w; 11 | h = _h; 12 | } 13 | 14 | // check for collision with the circle using the 15 | // Circle/Rect function we made in the beginning 16 | void checkCollision(Circle c) { 17 | hit = circleRect(c.x,c.y,c.r, x,y,w,h); 18 | } 19 | 20 | // draw the rectangle 21 | // if hit, change the fill color 22 | void display() { 23 | if (hit) fill(255,150,0); 24 | else fill(0,150,255); 25 | noStroke(); 26 | rect(x,y, w,h); 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /Website/section_4_challenges.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | Try these challenge prompts to modify the code we've written:
10 | 11 |random(), but for more natural motion, look at the Perlin noise example in Basics > Math > Noise2D in the Processing IDE. NEXT: ' . $next_onscreen . '
'; 7 | } 8 | ?> 9 | 10 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |