Archived

This topic is now archived and is closed to further replies.

constans

To clip or not to clip?

Recommended Posts

Let''s consider that I have cube which moves on the screen. No collision detection, so if it goes off-screen it returns back from the other side. Like this:
// Check if cube passed border

// Passed left or right border
if(cube.x_right < 0)
{
	cube.x_left = SCREEN_WIDTH;
	cube.x_right = cube.x_left + cube.width;
}
else if(cube.x_left > SCREEN_WIDTH)
{
	cube.x_right = 0;
	cube.x_left = cube.x_right - cube.width;
}

// Passed upper or bottom border
if(cube.y_bottom < 0)
{
	cube.y_top = SCREEN_HEIGHT;
	cube.y_bottom = cube.y_top + cube.height;
}
else if(cube.y_top > SCREEN_HEIGHT)
{
	cube.y_bottom = 0;
	cube.y_top = cube.y_bottom - cube.height;
}
And my question is that should I clip the part which is out of sight? Or is it ok without clipping?

Share this post


Link to post
Share on other sites