A86: Re: Re: Assembly-86 Digest V1 #945


[Prev][Next][Index][Thread]

A86: Re: Re: Assembly-86 Digest V1 #945




This isn't a game boy, you can't just move sprites and expect magical things
to happen :)  You must erase the old sprite when it moves.

There are many options available to you.  The first thing you will probably
try is to draw blank sprite over the old one.  Another method along the same
lines is to XOR the same sprite over the old sprite.  There is probably a
good reason to do this, but I've never tried to figure out it.  There are
better ways, anyway.

If your game doesn't have a background, the above method will work fine
(though it might get slow).  However, if you do have a background, then it
won't work.  In erasing the sprite, you'll also erase part of the
background!  So what's the solution?  Simple: save the background.

How do we do that?  Well, again, there are several ways.  The first way
you'll probably try (mainly because someone like Mardell already wrote a
routine that you can borrow) is to have the sprite routine save the
background.  This method  can be the fastest way to do it.  It depends on
how well the sprite routine is written.  It also depends on how fast the
routine to redraw the background is.

Another method that I came up with is tripple buffering or map buffering.  I
call it tripple buffering, as you'd have to have a double buffer for it to
be usable, but with page flipping it wouldn't exactly be tripple.  With this
method, you have a third buffer where the map or background is stored.  You
draw the background do this buffer whenever you need to update it.  Each
frame, you first copy the map buffer to the double buffer.  In effect, this
erases any and all sprites!

Then you redraw all sprites to the double buffer, and copy it to video ram.
Now, a copy may seem like it takes a while, but it's really not a long time
if you think about how long it can take to erase (by redrawing) several
sprites on the screen.  Time your sprite routine and see.  If you will have
few moving sprites, this method could be slower, because you have to redraw
everything, even if it didn't move.  But I see this it's best feature.  You
don't have to keep track of where stuff used to be...just move and redraw!


> hi, could anyone help me out with a little something...
>
> like, i have the putsprite routine which is very easy to find, and its
also
> very easy to use... but what if you wanted to move the sprite?  how do you
do
> that?  i mean, if you just move the coordinates, then it would just write
> over the last one and just screw everything up.  so how do you get the
sprite
> to MOVE???




References: