I am making a windows game project in C# and I am pretty new to coding. My program involves using the keyboard to move an object around the screen but I can not figure out one thing. How do I code it so my object does not go off the screen? As of right now I just have it displaying the object and have the object programmed to move with the arrow keys.
Test the objects position. If it's x-position is greater than the screen width, or less than 0 (it's off moved off the screen on the x-axis), adjust it accordingly. The same applies for the y-position.