Self-hatred

[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;

Categorised as: programming, school


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>