🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Bounding Box Question

Started by
3 comments, last by Mike00 23 years, 10 months ago
I read this in another thread: "If we were doing 2d collision detection on a 32x32 sprite then you''d do this: // The rect structure takes in 4 points which creates a // rectangle. The point order is LEFT(x1),TOP(y1), RIGHT(x2), // BOTTOM(y2) RECT BoundingBox = { 0, 0, 32, 32 };" I have a few questions. First, when you say 32x32, what exactly does that mean? How do you find out how big your object is? Next, how do you attach the bounding box to the object, so when the objext moves, the box does too? Thanks!
Advertisement
it means your sprite image is 32 pixels wide and 32 pixels wide.

you don''t attach the bounding box to your object.. just add the bounding box to the objects position and you should be able to figure out why that works then pick up a book cause that''s some pretty basic stuff.
Sprites always, (at least when ever I have heard of them) come with the sprite size with them.

So if you want to see if a 2D little box hit the ground at (x*,y0)

         []       []   ______[]_0,0    


you would do something like sprite current

if y position -32 = 0 then collision
else no collision

that is with the 0,0 at the bottom right.

This is the most simple collision detection I think in 2D.

Owen Choice
E Interactive
The reason Santa is so jolly is becuase he knows where all the bad girls live
Hmm ok thanks. But how do you find out what pixel your box is at in openGL? Like if I
glLoadIdentity()
glTranslatef(1.0f,0.0f,-5.0f)
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
how do I know how many pixels long each side is?

I'm not exactly sure what you mean by sprites though. What if I use GL_QUADS to make something? Is that considered a sprite?

Thanks

Edited by - Mike00 on September 4, 2000 1:59:39 AM
OpenGL don''t support sprites
you have to fake them with blended quads
(you can find me on IRC : #opengl on undernet)

This topic is closed to new replies.

Advertisement