Beginner's Guide to Game Programming Ep1 Part 9 Bounding Box Collision Detection
Uploader Comments (LusikkaMage)
Top Comments
-
Thank you very much for taking the time to produce such excellent video tutorials. I am studying computer games development at Southampton Solent University and for our next assignment for one of the units we have to design and create a game in C++ and allegro. These tutorials came in very helpful so thank you once again.
-
Your videos are AMAZING! I <3 them so much!
All Comments (39)
-
@LusikkaMage No, lol, I was assigning it a number but I figured out what I was doing wrong and I finally finished my game!!
-
@retromelon123 If you have a large rectangle (say, around the entire sprite), and then a smaller one inside (perhaps the character's head, specifically), you would do a test for only the large rectangle first.
If the large rectangle is not hit, it goes without saying that the small one is also not hit so you don't have to test.
If the large rectangle is hit, you'd do a second test with the small one to see if, say, it's a "head shot" and then react accordingly whether it's true/false.
-
what about if a small rectangle is completely encompassed by a bigger rectangle... in that case, there is a collision, but it would not be detected by this, right? :)
-
@CoderRach ok, makes more sense now, but what i'm having a huge issue with is:
something went HORRIBLY wrong. When I try to build with visual c++, it says Microsoft internal linker has stopped working, then it says there are build errors and I check and there are 2, both in "main.obj" which is a blank file that I didn't make. It's basically saying the file is corrupt. I tried to run the last successful build but it says something aobut some messed up binary stuff. What do I do?
-
@askmiller If you're storing the Y value of the top, Y value of the bottom, X value of the left, and X value of the right, then you ARE doing rectangular collision detection. I create a Rectangle struct/class in order to keep the code clean and more manageable.
-
@LusikkaMage why do you make rectangles? When I tried to make a collision box, I made 4 variables for each object. top, bottom, left, and right, and I gave each a value relevant to their x and y coordinates. Then I used your hit detection if statement and that's all I needed. Why would you make rectangles? Isn't it a lot more work than just having the value of the edges of the hit detection update constantly?
-
thanks a lot! =] you're awesome!
-
@EoN604 Meh, i knew i just was confused, I have made at least 10 games now ( Using C#, though )
Hey these tutorials have helped me so much with my programming and everything that i have created so far has worked perfectly except I don't fully understand making the Rectangle Header, all I have in there right now is the "struct Rect {int x, y, w, h;};", yet when I include the Rectangle header into let's say the Stick Header and try to assign the variables "x, y, w, or h" a number, it tells me, identifier "variable" is undefined, what am I doing wrong? Please help, your the best :D
ForeverMick32 1 month ago in playlist Beginner Game Programming 1 Allegro 4
@ForeverMick32 Are you literally trying to assign something to "variable"? It sounds like you're using that as a variable name, but it doesn't actually exist.
LusikkaMage 4 weeks ago
OK.... I Dont get it... I Get this video but... few videos ago we were at initializing and now we should have billions of classes that we never made so.... WUT?
FrozenMasters 1 year ago
@FrozenMasters I'm not teaching you guys to use classes; you guys should know this before watching this tutorial. I am teaching you the elements of the library, as well as some basic functionality you need- say, collision detection.
Anyone who doesn't have an intermediate understanding of C++ should not be utilizing my BGtGP tutorials.
LusikkaMage 1 year ago
Couldn't you just find the area of the stick's collision box and the person and then see if one of the objects area's changed? Sorry, I'm just really, really confused.
cplusplusgamer 1 year ago
@cplusplusgamer Not really sure what you're asking? Only check for collision on the movement of an object, rather than every cycle?
LusikkaMage 1 year ago