Self-hatred

Posts Tagged ‘collision’

[XNA] Keeping a sprite on screen

I’m making a class for collision detection right now. if (rectangle1.X < 0) rectangle1.X = 0; if (rectangle1.Y < 0) rectangle1.Y = 0; if (rectangle1.Y + texture1.Height > gameHeight) rectangle1.Y = gameHeight – texture1.Height; if (rectangle1.X + texture1.Width > gameWidth) rectangle1.X = gameWidth – texture1.Width;