TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: ALL
from: DAVID AUKERMAN
date: 1998-03-15 15:46:00
subject: Code FAQ 03/98 09/12

'>>> Page 9 of CODE0398.FAQ begins here.
   released recently, you may or may not be able to find it on a
   local BBS.  Most likely no, so get in touch with me, Dave Shea,
   and I'll see what I can do to hook you up with it."
   If you can't find Dave anywhere, contact me or the QUIK_BAS echo
   and we'll see if we can track him down.
   Back to animation.
   The first thing you have to do is set aside memory for your
   sprite using the DIM command.  For example:
   DIM Array%(NumberOfElements)
   Array% is the name of the array you're using to store the sprite
   data.  In this section of the FAQ, I won't explain what an array
   is.  Just think of it as a really big variable that we will use
   to store our picture.  How do you determine the number of bytes
   you need to set aside for this array?  It depends on your screen
   mode.  We will assume SCREEN 13 from now on, in which each pixel
   requires exactly one byte of memory.  So, to determine the
   amount of memory needed, the formula is:
   NumberOfElements = ((XValue * YValue) / 2) + 12
   The extra 12 bytes are to store the (x,y) dimensions of the
   array.  You must divide by two because each element of Array%
   is an integer value, 16 bytes, and we only need 8.  If you don't
   understand, don't worry.  Just follow the formula.
   So where do the XValue and YValue come from?  Like I said, a
   sprite is a rectangle, so the XValue is the number of pixels
   across the sprite horizontally (left to right), and Y is the
   number of pixels going up and down.  Once you have your graphic
   on the screen, try drawing a box around it.  Once you have a box
   that completely surrounds the graphic, use the X and Y values
   for the box as the same for your graphic.  If you're having
   troubles with this, use the following formula for a box that
   completely surrounds your graphic:
   LINE (x1, y1) - (x2, y2), 31, B
   x = (x2 - x1) : y = (y2 - y1)
   Okay, so now I have everything set up, how do I store my picture
   in the array?  Use the GET command.  It's as easy as this:
   GET (x1, y1) - (x2, y2), Array%
   The x1, y1, x2, and y2 are the exact same as in the LINE command
   above, and the array Array% is the one we dimensioned above.
   So, now you have the graphic in memory, you can clear the screen
   so it's not still on there.
   Animation starts here.  Once you have all the sprites (or all
   the different "frames" of your cartoon) stored in arrays, you
   will most likely want to stick them back on the screen at a
   certain time in your program.  This is done through the PUT
   command.  For example:
   PUT (50, 50), Array%
   That will stick the graphic you have in Array% at position
   (50, 50) on the screen.  Easy as that.
   So, now I have this going for me, how do I actually animate?
   Basically, you stick your picture on the screen, delay for a
   bit so you can see it, erase it, and immediatly stick another
   picture on the screen at a different location, and so on.  The
   one problem with this is that, for a very short time, there is
   no picture on the screen.  This will cause the animation to
   flash a certain amount, no matter how fast your computer is.
   There is one way that slightly avoids this problem, but it's not
   a complete solution.  This will work only if you are using small
   sprites, and only if you don't animate near the top of the
   a bit, it can also be used in place of a delay loop.)  This
   command is called the vertical retrace, and it goes like this:
       WAIT 986, 8    (or WAIT &H3DA, 8....)
   That will help, but only a little bit.  The following example is
   a little animation of a guy running, and it uses the techniques
   described above.
[begin]
'>>> Page 9 of CODE0398.FAQ ends here. Continued on next page.
___
 * SLMR 2.0 * Death has been proven 100% fatal to all stupid people.
--- Maximus/2 3.01
---------------
* Origin: The I.O. Board - 4GB -XX- V34+ (1:2255/10)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.