TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: ALL
from: ROBERT KOHL
date: 1998-05-13 21:37:00
subject: CodeFAQ Part 9 of 11

---------------------------- CodeFAQ Part 9 of 11 ---------------
   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]
   ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
   ' RUN.BAS  by  Dave Shea
   ' Released to Public Domain on January 18th, 1997.
   '
   ' Compile: MicroSoft QuickBasic 4.5, PDS 7.1
   '
   ' Desc: A simple animation. Demonstrates some techniques behind
   ' animating in QB.
   '
   ' (Use at your own risk)
   ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
   CLS : SCREEN 13               'Set Screen 13, of course!
   PSET (25, 71), 31: DRAW "rdld2l2ngr3fnehld3rfrdngulhlg2lh"
   PSET (45, 71), 31: DRAW "rdld2lgnder2dnr2ld2rfdnguhld2lg"
   PSET (65, 71), 31: DRAW "rdld2ldrnednrddrfndhldlg"
   PSET (85, 71), 31: DRAW "rdld2lgnderdnr2d2rfdnguhlgdl2"
                                 'The above will draw four
                                 'different frames of a Stick man
                                 'running.
   DIM Guy1%(134), Guy2%(134), Guy3%(134), Guy4%(134)
                                 'Set aside the memory required for
                                 'each frame.
   GET (16, 69)-(34, 82), Guy1%  'Stick each frame into memory
   GET (36, 69)-(54, 82), Guy2%  '(X and Y values calculated by
   GET (56, 69)-(74, 82), Guy3%  ' pure trial and error. =u)
   GET (76, 69)-(94, 82), Guy4%
   CLS                           'Guess what THIS does!
   FOR a = 1 TO 300 STEP 2                'Begin Loop
    b = b + 1: IF b = 5 THEN b = 1        'Increase b until it
                                          'reaches a value of 5,
                                          'reset it to 1
    IF b = 1 THEN PUT (a, 100), Guy1%     'Determine which frame to
    IF b = 2 THEN PUT (a, 100), Guy2%     'PUT, then PUT it.
    IF b = 3 THEN PUT (a, 100), Guy3%
    IF b = 4 THEN PUT (a, 100), Guy4%
    WAIT 986, 8                           'Wait for Vertical
                                          'Retrace
    Start = TIMER                         'Small delay loop to slow
    WHILE TIMER < Start + .1: WEND        'it down a bit.
    IF b = 1 THEN PUT (a, 100), Guy1%     'Erase current frame by
    IF b = 2 THEN PUT (a, 100), Guy2%     'PUTting it again.
-------------- CodeFAQ ends Part 9 of 11 ------------------------
Robert (Bob) Kohl  Rio Rancho, New Mexico
Home Page:  http://www.geocities.com/SiliconValley/Way/7854
            http://members.tripod.com/~Bob_Kohl/index.html
Internet: bobakohl@abq.com  bobakohl1@juno.com  barbarianh@aol.com
--- Blue Wave/DOS v2.30
(1:301/45)
---------------
* Origin: * Binary illusions BBS * Albuquerque, NM * 505.897.8282 *

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™.