Jump to content
  • Advertisement
Sign in to follow this  
essbee

OpenGL Screen resolution collision

This topic is 2777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there,

I have a little problem here with OpenGL when I try to get the ClientSize.Height and Width. It returns an integer of 262 for both so my calculations to detect if the player ship is out of the window are wrong.


private void UpdateCollisions()
{
if (_playerCharacter.GetBoundingBox().Y <= 0)
{
moveUp = false;
}
else
{
moveUp = true;
}

if (_playerCharacter.GetBoundingBox().Y >= _clientHeight)
{
moveDown = false;
}
else
{
moveDown = true;
}
...


P.S: _clientHeight is the height I'm getting in the constructor (one of the two 262 int).

This is an example of what I'm trying to do but the ship can only move from left to right from about the center to the 1/4 from the right of the screen. He can't go up but he can go down for something that seems like infinite (well, it goes off screen).

I'm sure I'm not the only one who tried to do something similar to this before, I would appreciate some help. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
I don't think this has much to do with OpenGL, it certainly has no functions or objects like ClientSize.Height/Width.

Is that some win32 api functions? In any case I think you're in the wrong forum.

Share this post


Link to post
Share on other sites
Update: I have something that perfectly works (for my screen at least).


// I declare these rectangles and made them look like lines so they are around the level and detect collisions.
RectangleF _boundsDown = new RectangleF(-1366 / 2, -768 / 2, 1024, 1);
RectangleF _boundsLeft = new RectangleF(-1366 / 2, -768 / 2, 1, 800);
RectangleF _boundsTop = new RectangleF(-1366 / 2, 768 / 2, 1024, 1);
RectangleF _boundsRight = new RectangleF(1366 / 2, -768 / 2, 1, 800);
...
// My conditions are like this...
if (_playerCharacter.GetBoundingBox().IntersectsWith(_boundsTop))
{
moveUp = false;
}
else
{
moveUp = true;
}
...


It's cool it works but I would like to make it for any screen resolution :/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!