📄 svgabc25.txt
字号:
at a right angle to your index finger. It should be at a right
angle to your thumb as well. This represents the three axes.
The index finger is the X axis, the second finger is the Y axis
and the thumb is the Z axis. The easiest way to remember
rotation directions in this system is cyclically. A positive
rotation about the X axis rotates the Y axis into the Z axis. A
positive rotation about the Y axis rotates the Z axis into the X
axis. A positive rotation about the Z axis rotates the X axis
into the Y axis.
After doing all necessary 3-D transformations, projection onto
the 2-D computer screen is required. Although the computer
screen's coordinate system does not follow mathematical
conventions, the D3PROJECT function automatically takes care of
all conversions. The programmer only needs to draw the resulting
object on the screen with FILLCONVEXPOLY, FILLPOLY or a series of
DRWLINEs.
THE CONCEPT OF SPRITE GRAPHICS
The key to sprite graphics is the assumption that only a small
percentage of the pixels in a graphics block are used by the
animation and the remaining pixels should be treated as
transparent, revealing the background behind the sprite. The
sprite routines in this library only act on non-transparent
colors, thus, saving time by ignoring a large number of pixels.
When retrieving the background for a sprite, prior knowledge of
the sprite itself permits obtaining background only where it is
necessary.
6
The following steps outline an example of the recommended
procedure for using the sprite functions:
1. draw the sprite on the screen - a white stick figure on a
black background, for example
2. use BLKGET to place the sprite in an array STICK
3. use SPRITEGAP to simultaneously retrieve the background into
BACKSTICK and place STICK on the screen, declaring black as
the transparent color
4. use SPRITEPUT to replace the background BACKSTICK in the
same location as step 3
5. repeat steps 3 and 4 as many times and in as many locations
as desired
EXTENDED MEMORY SUPPORT
With the higher screen resolutions, more memory may be needed for
data storage. For this reason extended memory support is
provided. Accessing extended memory requires the computer to
switch into protected mode. The process of switching into
protected mode and returning is handled by the extended memory
manager, usually HIMEM.SYS. The switch is relatively slow.
Therefore, it should be used as fast storage access since it is
much faster than disk access.
Extended memory access is also limited by the number of available
handles. The limit is controlled by a switch on the extended
memory manager's command line and normally defaults to 32. Also,
it is imperative that all allocated extended memory blocks be
freed before the program terminates. Unfreed memory blocks will
be unavailable until the computer is rebooted.
CONVENTIONS USED IN THIS MANUAL
All parameters, other than strings, passed to and from functions
and procedures in this QuickBasic library are short (two byte)
integers. No floating point values are used.
Whenever a pixel is written on the screen, a mode is required.
Unless otherwise noted, there are four possible modes: SET, XOR,
OR and AND. These modes are represented by the numbers one
through four respectively. Technically, SET is the fastest mode.
However, XOR maybe the most useful. XOR'ing a point twice with
the same color returns the original color. This can be used to
cover and uncover graphics. In addition when a reference to a
color index is made, only values between and including 0 and 255
are valid. Any integer will work, but only the lowest eight bits
are recognized.
7
BLKGET
PROTOTYPE
SUB BLKGET (X1%, Y1%, X2%, Y2%, GfxBlk%)
INPUT
X1, Y1 - top left corner of block
X2, Y2 - bottom right corner of block
OUTPUT
If declared as a function, BLKGET returns 1 if successful, 0
if failed.
GfxBlk - integer destination array holding retrieved bitmap
USAGE
BLKGET stores the pixel data contained within the block
defined by (X1, Y1)-(X2, Y2) in the variable referenced by
GfxBlk. GfxBlk must be dimensioned as a short integer array
with a size in integers equal to
[(X2-X1+1)*(Y2-Y1+1)] / 2+3.
Note, however, that GfxBlk can be quite large. If the size of
GfxBlk is insufficient, BLKGET will overwrite any data in
memory contained beyond GfxBlk and may possibly cause the
system to crash. BLKGET enforces X2 X1 and Y2Y1. Also, the
coordinates must be valid on the screen at the current
resolution.
The bitmap is stored such that the first integer in the
destination array is the width and the second integer is the
height. The remaining bytes are the bitmap raster data stored
by rows starting at the top of the block.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
BLKPUT, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
SPRITEGET, SPRITEPUT, XMSBLKGET, XMSBLKPUT
EXAMPLE
REM PLACES 1/4 OF A CIRCLE AT THE CENTER OF THE SCREEN
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM BLOCKDATA(0 TO 483) AS INTEGER
IF WHICHVGA = 0 THEN STOP
DUMMY=RES640
8
DRWCIRCLE 1, 10, 30, 30, 20
FILLAREA 30, 30, 10, 7
BLKGET 0, 0, 30, 30, BLOCKDATA(0)
BLKPUT 1, 320, 240, BLOCKDATA(0)
WHILE INKEY$ = ""
WEND
DUMMY=RESTEXT
END
9
BLKPUT
PROTOTYPE
SUB BLKPUT (Mode%, X%, Y%, GfxBlk%)
INPUT
Mode - pixel write mode (SET=1, XOR=2, OR=3, AND=4)
X, Y - location for top left corner of block
GfxBlk - integer source array
OUTPUT
no value returned
USAGE
BLKPUT places the pixel data contained in the variable
referenced by GfxBlk on the screen. The top, left corner of
the block is specified by (X, Y). Any (X, Y) is acceptable
and any portion of the block that lies outside of the
currently defined viewport will not be drawn.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
BLKGET, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
SPRITEGET, SPRITEPUT, PCXPUT, SETVIEW, XMSBLKGET, XMSBLKPUT
EXAMPLE
See BLKGET
10
BLKRESIZE
PROTOTYPE
SUB BLKRESIZE (NewXSize%, NewYSize%, SourceGfxBlk%,
DestGfxBlk%)
INPUT
NewXSize, NewYSize - size of resulting bitmap in DestGfxBlk
SourceGfxBlk - integer source array
OUTPUT
no value returned
DestGfxBlk - integer destination array holding resized bitmap
USAGE
BLKRESIZE takes the bitmap in SourceGfxBlk and scales it up or
down according the to values passed in NewXSize and NewYSize.
The resulting bitmap is returned in DestGfxBlk which should
already be declared with a size calculated according to the
equation in BLKGET. NewXSize and NewYSize should not be zero.
SEE ALSO
BLKGET, BLKPUT, BLKROTATE
EXAMPLE
REM RESIZE A BITMAP
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM SRC%(0 TO 32000)
DIM DST%(0 TO 32000)
IF WHICHCPU < 386 THEN END
IF WHICHVGA = 0 THEN END
VMODE=VIDEOMODEGET
IF RES640 <> 1 THEN
DUMMY = RESTEXT
END
END IF
X1 = 0
Y1 = 0
X2 = 50
Y2 = 50
FOR I = 0 TO 25
XA = (RND * X2 - X1) + X1
YA = (RND * Y2 - Y1) + Y1
XB = (RND * X2 - X1) + X1
YB = (RND * Y2 - Y1) + Y1
C = RND * 16
11
DRWLINE 1, C, XA, YA, XB, YB
NEXT I
DRWBOX 1, 15, X1, Y1, X2, Y2
BLKGET X1, Y1, X2, Y2, SRC(0)
X1 = GETMAXX \ 2
Y1 = GETMAXY \ 2
X = SRC(0) + 1
Y = SRC(1) + 1
BLKRESIZE X, Y, SRC(0), DST(0)
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
FOR I = X TO X + 50
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
BLKRESIZE I, I, SRC(0), DST(0)
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
SDELAY 3
NEXT I
FOR I = X + 50 TO X - 50 STEP -1
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
BLKRESIZE I, I, SRC(0), DST(0)
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
SDELAY 3
NEXT I
FOR I = X - 50 TO X
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
BLKRESIZE I, I, SRC(0), DST(0)
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
SDELAY 3
NEXT I
VIDEOMODESET VMODE
END
12
BLKROTATE
PROTOTYPE
FUNCTION BLKROTATE% (Ang%, BackFillColor%, SourceGfxBlk%,
DestGfxBlk%)
INPUT
Ang - integer degree to rotate source bitmap
BackFillColor - index to color in current palette to fill
blank space in DestGfxBlk
SourceGfxBlk - integer source array
OUTPUT
BLKROTATE returns 1 if successful, 0 if unsuccessful.
DestGfxBlk - integer destination array holding rotated bitmap
USAGE
BLKROTATE takes the bitmap in SourceGfxBlk and rotates by the
number of degrees specified in Ang. The bitmap rotation
algorithm is a three-pass shear technique modified to make
efficient use of this library's internal buffers. Blank space
around the newly rotated block is filled with the color given
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -