HTML5 Game 2 – Part 2: Rectangles Intersection



Redone Version: http://youtu.be/un_eBRNazyc

Next: http://www.youtube.com/watch?v=9D2IhKYegEg
Setting up the intersection between shapes in the rectangle.

If you are having trouble with your code try and copy the code from the source file below.

Source: http://www.farrisarts.com/demo/backup/rectangle.js

Twitter ► http://brentfarris.com/twitter
Website ► http://brentfarris.com
GitHub ► http://brentfarris.com/github

source

Related posts

Unreal Engine 6: Devasa Metaverse ve Verse Devrimi Geliyor!

PLAYSTATION a besoin de VOUS 🚨 Suikoden plusieurs annonces 😍 Tony Hawk de retour 🛹

Ninja Gaiden 4 – Game Overview | Xbox Developer Direct 2025

3 comments

@BrentFarris January 19, 2025 - 4:09 pm
Note that I did intersection all wrong, when making my library in C++ it dawned on me that I could just check if either rectangle contains each others corners. Here is an example: if (Contains(rect.x, rect.y) || Contains(rect.x + rect.width, rect.y) || Contains(rect.x, rect.y + rect.height) || Contains(rect.x + rect.width, rect.y + rect.height)) return true;
@BrentFarris January 19, 2025 - 4:09 pm
@limited06 You may want to show me an example of what you mean as all of the checks are either >= or <= so there shouldn't be "shape.X is equal to the this.X" (the equal to) or "shape.Y is less than this.y" (less than). Both of these operators should have an equal and a greater than or less than. I posted the code to copy and check in the description, it may look different than what is in this video, as I deleted the file I used in this video by accident
@limited06 January 19, 2025 - 4:09 pm
I believe theres an error in your Intersections code. When the shape.X is equal to the this.X and shape.Y is less than this.y, the shape can go straight through the "this" block. Let me know if you want me to show you example of it.

Comments are closed.

Add Comment