Screen resolution collision

Started by
2 comments, last by essbee 13 years ago
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!
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.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Well, I use C# with OpenGL. I thought that was related, maybe I'm wrong.
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 :/

This topic is closed to new replies.

Advertisement