Board index » delphi » animation with AND/XOR masks in TP6.0

animation with AND/XOR masks in TP6.0

Argh!

I am in need of help before I pull all of the hair out of my head. If
anyone can help me, it would most certainly prevent a visit to the
Hair Club for Men.

Here's the situation: I need to animate a small bitmap across a
complex background. Simple enough. If you XOR this bitmap
across the background, the bitmap will be inverted or changed
as it passes over various background pixels. This is understandable.

Apparently, if one were to use a combination of AND and XOR masks,
the bitmap will maintain its proper image and colors no matter what
it passes over in the background. Here's an algorithm of what I am doing:

        a. Get piece of background at x,y
        b. put piece of background back at x,y
        c. put bitmap at x,y using AND
        d. put bitmap at x,y using XOR
        e. time delay
        f. put piece of background back at x,y
        g.increment x/y
        h.repeat (ie. return to 'a').

This is all fine and dandy, except when I do this I am seeing the bitmap
boundaries (ie. the rectangular GetImage boundaries) as well as the
bitmap itself. I don't want this. When XORing and image to a background,
you don't see the GetImage boundaries, and like I mentioned before --
the "tag team" AND & XOR method is supposed to NOT show the boundaries.

If anyone can provide any hints, tips or pointers (excuse the pun) I would
actually go to sleep tonight.

Thanks

Todd:bboT
--
Todd:bboT
----------------
Todd Save the Queen

 

Re:animation with AND/XOR masks in TP6.0


Quote
>         a. Get piece of background at x,y
>         b. put piece of background back at x,y
>         c. put bitmap at x,y using AND
>         d. put bitmap at x,y using XOR
>         e. time delay
>         f. put piece of background back at x,y
>         g.increment x/y
>         h.repeat (ie. return to 'a').

First of all, that is an EXTREMELY clever procedure. I am sorry to hear it
doesn't work like you would like it to.

This method is different, but is really fast, and can be easily adapted to
different screen modes.

Let's assume you are using 320x200x256 (any chained variant works too..)

1. First, create a "logical page", by making a 64000 byte array using
pointers.          This is an array the size of a 320x200 screen.

2. Next, flip the background image to this page.

3. Draw the sprite to the screen.

4. Wait for verticle retrace, whatever else you need here...

5. Copy a section of the logical page over your sprite.

6. Repeat from 3.

A simple Mode $13 graphics unit will do the trick, you don't need any assembly.

I'd be happy to send you a little demo w/source if you need that.

<cg...@hooked.net>

Other Threads