1
Graphics / Simulating Window-Border Collision!
« on: August 05, 2011, 09:02:20 pm »
Hey!
Got this tiny 'lil problem now... I'm trying to keep my moving sprite from going outside the window borders, currently using:
I originally had it as
but that froze the program as soon as it executed... Umm, am I using the wrong functions for checking this, any ideas?
Got this tiny 'lil problem now... I'm trying to keep my moving sprite from going outside the window borders, currently using:
Code: [Select]
float KeyMove = 0.10f;
sf::FloatRect BorderColl(0, 0, 800, 600);
sf::Vector2f BlobPosition = Blob.GetPosition();
bool CheckBorderColl = BorderColl.Contains(BlobPosition);
if (CheckBorderColl == 1);
{
if (ShiftKeyDown)
KeyMove = 0.3f;
if (LeftKeyDown)
Blob.Move(-KeyMove, 0);
if (RightKeyDown)
Blob.Move(KeyMove, 0);
if (UpKeyDown)
Blob.Move(0, -KeyMove);
if (DownKeyDown)
Blob.Move(0, KeyMove);
if (GKeyDown)
Blob.Rotate(KeyMove);
if (HKeyDown)
Blob.Rotate(-KeyMove);
}
Win.Clear();
Win.Draw(Blob);
Win.Display();
}
I originally had it as
Code: [Select]
while (CheckBorderColl)
but that froze the program as soon as it executed... Umm, am I using the wrong functions for checking this, any ideas?