DECLARE SUB DQBput (BYVAL Layer, BYVAL x, BYVAL y, BYVAL SpriteSeg,
BYVAL SpriteOff)
Layer - Layer where to draw the sprite
x - X position of upper left corner of the sprite
y - Y position of upper left corner of the sprite
SpriteSeg - Segment of the array holding the sprite data; use VARSEG
SpriteOff - Offset of the array holding the sprite data; use VARPTR
none
Draws the sprite contained into the given array on specified layer, at the given coordinates. DQBput can operate both in transparent and solid mode: when the first mode is set, pixels with color 0 of the sprite are skipped, allowing a transparent put, when the second mode is set, all the pixels are copied to the layer, destroying the background. By default the put mode is set to transparent, but it can be changed at any time by simply calling DQBsetTransPut and DQBsetSolidPut.
DQBput is affected by the clipping box, so pixels outside this box will not be drawn. The sprite data format is compatible with normal GET and PUT, so you can get you sprite data by calling either GET or DQBget. See also DQBfPut, DQBsPut, DQBrPut and DQBbPut.
*****************************************************************************
' All integers for speed
DEFINT A-Z
'$INCLUDE: 'DIRECTQB.BI'
' Let's initialize the library with one extra layer and no sounds nor EMS
IF DQBinit(1, 0, 0) THEN DQBclose: PRINT DQBerror$: END
' We're going to use 15 sprite 16x16 pixels each; let's call DQBsize to
' know the dimension of our sprite array (we'll store all the sprites into
' the same array) in bytes
Size = DQBsize(0, 0, 15, 15)
' Our array is made of INTEGERs, so we divide Size by 2
DIM Sprite((Size \ 2) * 15)
' Let's prepare our sprites
FOR i = 0 TO 14
' Let's clear layer 1
DQBclearLayer 1
' Draws a frame of our sprite
DQBbox 1, 0, 0, 15, 15, 4
DQBline 1, (15-i), 15, i, 0, 40
DQBline 1, 15, i, 0, (15 - i), 40
' Saves the frame into our array
DQBget 1, 0, 0, 15, 15, VARSEG(Sprite(0)), VARPTR(Sprite(0)) + (Size * i)
NEXT i
DQBinitVGA
FOR i = -16 TO 320
' Empties layer 1
DQBclearLayer 1
' Finds what frame to draw
Frame = ((i + 16) \ 2) MOD 15
' Draws our frame into layer 1
DQBput 1, i, 92, VARSEG(Sprite(0)), (VARPTR(Sprite(0)) + (Size * Frame))
' Waits for vertical retrace 1 time
DQBwait 1
' Copies layer 1 onto the screen
DQBcopyLayer 1, VIDEO
NEXT i
' Ends program
DQBclose
*****************************************************************************