# samsandeep_e

Members

8

## Community Reputation

123 Neutral

• Rank
Newbie

As Endurion pointed out just use the bool in the condition for collision. if(g_bBlock[4].m_bActive_three==true) { if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f) { ystep = -ystep; g_bBlock[4].m_bActive_three=false; } } But trust me, there are much more efficient ways of detecting collision and removing the blocks.  The one you are using is probably the easiest but not accurate in many cases.
2. ## Rectangle Line collision problem

Hi, I'm working on 2d top down car racing game.  Could anyone tell me the simplest way of the detecting the collision between the car (rectangle) and the track edges(lines).  The logic I'm currently using is not working as I expected.  I tried to check for line to line collision between the car's rectangle (4 lines) and the track lines.  Also if it not vector based it would be great, so I could use it right away in my  project.
3. ## How do I rotate a rectangle with the four vertices

Wow awesome.. it works...     Phew..  and it is so simple.. :|
4. ## How do I rotate a rectangle with the four vertices

Thank you so much...    I'll try it out and let you know.. :D
5. ## How do I rotate a rectangle with the four vertices

Hi,   Could anyone please help me out here?   I have the top left corner co ordinates of a rectangle.  And also the width and height.  Now, say, I want to rotate the rectangle 30 deg with the top left vertex as it s axis.  How do I calculate the four vertices.     I'm trying to do this in opengl without using the glRotatef function, but for some reason the texture gets distorted with the rectangle rotates.   I'm currently using this logic.       currentTopLeftX = Vertices[ 0 ].x; currentTopLeftY = Vertices[ 0 ].y; currentTopRightX = Vertices[ 0 ].x + w*cos(angle*PI/180); currentTopRightY = Vertices[ 0 ].y + w*sin(angle*PI/180); currentBottomRightX = Vertices[ 0 ].x + w*cos(angle*PI/180) - h*sin(angle*PI/180); currentBottomRightY = Vertices[ 0 ].y + w*sin(angle*PI/180) - h*cos(angle*PI/180); currentBottomLeftX = Vertices[ 0 ].x + h*sin(angle*PI/180); currentBottomLeftY = Vertices[ 0 ].y + h*cos(angle*PI/180);
6. ## Collision Detection HELP! openGL SDL c++, 2D top down racing game

Thanks.   I already have the co-ordinates for the track.  I've drawn the track by drawing many bezier curves from quadratic equations, where the last point of the first curve is the first point of the second curve and so on.  I have fixed distance for the width of the track, so i draw the other side as well.  So, i guess i have all the points needed to calculate the collision.
7. ## Collision Detection HELP! openGL SDL c++, 2D top down racing game

Thanks for the reply.   But I'm first looking to check the collision between the track edges and the car, so the car always stays in the track.  Currently there are no AI cars, I'm planning to do that after the car-track collision is fixed.
8. ## Collision Detection HELP! openGL SDL c++, 2D top down racing game

Hi,   I'm trying to build a simple top down car racing game using SDL, I'm using openGL for rendering.  I've drawn the track using parallel bezier curves and taking the points and drawing them as Quads with texture.  I've got the car physics up and running.   Now, I would like start off with the collision between the car and the track.  Could anyone help me out by giving a simple and practical solution for this.