Bounding Box Question
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!
September 03, 2000 10:22 PM
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.
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)
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement