Archived

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

constans

To clip or not to clip?

Recommended Posts

constans    122
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
constans    122
What if I'm using DirectDraw's blitting function and simple rect which I fill with color? Therefore I'm not using loaded bitmap.

[edited by - constans on January 15, 2004 11:02:21 AM]

Share this post


Link to post
Share on other sites