--------------------------- CodeFAQ 8 of 11 ---------------------
'CALL InterruptX(&H10, Register, Register)
'CharSegment% = Register.ES: CharOffset% = Register.BP
'CharWid% = 8: CharHgt% = 16
DEF SEG = CharSegment%
XX% = X%
FOR Char% = 1 TO LEN(Text$)
Ptr% = CharHgt% * ASC(MID$(Text$, Char%, 1)) + CharOffset%
FOR Ln% = 0 TO CharHgt% - 1
BitPattern& = PEEK(Ptr% + Ln%) * 256&
LineFormat% = (BitPattern& - 32768) XOR -32768
LINE (XX%, Y% + Ln%)-STEP(CharWid% - 1, 0), Culler%_
, , LineFormat%
NEXT
XX% = XX% + CharWid%
NEXT
DEF SEG
END SUB
[end]
10) HOW CAN I ANIMATE SPRITES IN QB?
First thing, what's a sprite? Basically, it's a rectangle box
that has a picture in it. In something like cartoon animation,
they would be referred to as frames. So when you're animating
in QB, you're essentially doing the same thing that you would do
if you were to create a cartoon, just on a smaller scale.
So how do you create sprites? QB has a variety of graphics
functions (DRAW, LINE, CIRCLE, PSET, etc.) at your disposal.
They are quite cumbersome to use, so you might find it difficult
to get started. You may want to keep your eyes open for a QB
graphics editor; there are probably a lot of them.
Coincidentally (?), Dave Shea has written a graphics program
for QB:
"Spectra.13 was designed specifically for drawing graphics in
QB. It is totally mouse-controlled, has a handy pop-up menu,
features many handy utilities (draw, erase, paint, line, circle,
filled circle, box, filled box, text, Bitmap loading, palette
manipulation, save & load pictures, save & load icons, on-line
help, etc. etc. etc.) It's probably the most comprehensive QB
drawing program available, or at least the best of what I've
seen."
You can find Spectra.13 at http://www.ocis.net/~dshea/qb or, if
you have a question for Dave himself, you can e-mail him at
dshea@mail.ocis.net .
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%
-------------- CodeFAQ ends Part 8 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 *
|