Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Beginner's Guide to Game Programming Ep1 Part 9 Bounding Box Collision Detection

Loading...

Sign in or sign up now!
9,715
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 30, 2009

The Beginner's Guide to Game Programming:
A Problem Solving Approach
Episode 1: Makin' Pickin' Sticks
Part 9: Bounding Box Collision Detection

This is a written and video tutorial created to teach the basics of Allegro and SDL as well as game programming in general, while encouraging the newbie to code it out themselves.

Vimeo page:
http://vimeo.com/moosader

You can get the written version and other things at my site:
http://www.moosader.com

Playlist link:
http://www.youtube.com/view_play_list?p=B9C8BC6F495BD17E

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (LusikkaMage)

  • 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 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.

  • 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 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.

  • 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 Not really sure what you're asking? Only check for collision on the movement of an object, rather than every cycle?

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!

see all

All Comments (39)

Sign In or Sign Up now to post a comment!
  • @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 )

Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more