[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Anybody got info on fast sprite clipping?
Clipping compiled shapes is....possible, but not what you think. To clip
with a compiled shape you have to compile another shape that appears to
be 'clipped'. :-) For clipping behind other objects, the best way to do this
is to draw the objects in the correct order, unless you are doing something
like a Sierra style game with big foreground objects in which case a big
foreground mask for the screen can be used to overlay the background onto
the object.
For fast clipping of bitmapped objects to screen bounds with a normal drawing
routine....vertical is easy, if clipping off the bottom of the screen, just
chop the appropriate number of lines of the height counter when you go through
the loop. When clipping off the top, you also have to add the appropriate
offset into your shape data to skip the first x lines.
Horizontal clipping isn't actually that hard. The way I do it is: for clipping
off the right side, take the width down as much as possible (to a word boundary
) and then calculate how many (1-4) other pixels must be clipped and use the
result as an offset into a table of masks to use to preserve the other pixels
(since you'll be crossing a line boundary). Hope this helps.
--
-------------------------------
- Nate Trost GEnie:N.TROST -
- b45075@achilles.ctd.anl.gov -
-------------------------------