DQBplayFLIstep
SUB

Prototype

DECLARE SUB DQBplayFLIstep (BYVAL Layer)

Parameters

Layer - Layer where the frame has to be drawn onto

Returns

none

Description

Decodes the next frame of a FLI file onto a specified layer. The animation must have been opened with DQBopenFLI before calling this function; on errors DQBplayFLIstep will do nothing. When the last frame is reached, this sub will automatically restart from the first one, so it's up to the user to stop the animation at the right time. It's also up to the user to add a proper delay before copying the frame onto the screen: by the way, DQBopenFLI returns both the total number of frames and the speed factor of the FLI file to be opened. The speed factor can be used as a parameter to the DQBwait function, to achieve the default animation speed.

Notes:

Of course you can decode each frame directly onto the screen, but as explained into the description of the DQBplayFLI routine, this could not look so good on older computers... Also, keep in mind that by calling this function, the palette may change at any time as the FLI animation is playing. In addition, you should know that when a new frame is decoded onto a layer, only the parts of it that are changed from the last frame are drawn (that's the FLI standard) so if you plan to draw some moving stuff over the animation, you should always decode each frame onto the same layer, copy this layer onto a new one, and then draw your own stuff on this last one before copying it on the screen.

Example

*****************************************************************************

' This program does the exact thing as the example of DQBplayFLI, but this
' one uses the three functions DQBopenFLI, DQBplayFLIstep and DQBclose to
' achieve the result.

' All integers for speed
DEFINT A-Z

'$INCLUDE:'DIRECTQB.BI'

' Let's declare two variables to hold the number of frames and speed factor
DIM FramesNumber AS INTEGER, SpeedFactor AS INTEGER

' Initializes the library with one extra layer and no sounds nor EMS
IF DQBinit(2, 0, 0) THEN DQBclose: PRINT DQBerror$: END

' Prompts the user for the FLI file name
INPUT "Enter full FLI file name (hit enter to quit): ", FileName$

IF FileName$ = "" THEN DQBclose: END

' Frees 64K of memory for animation decoding
dummy& = SETMEM(-66000)

' Opens the animation file and gets infos on it
IF DQBopenFLI(FileName$, FramesNumber, SpeedFactor) THEN
  ' An error has occured
  DQBclose
  dummy& = SETMEM(66000)
  PRINT DQBerror$: END
END IF

' Shows some stats to the user
PRINT FileName$ + " contains" + STR$(FramesNumber) + " frames and has a ";
PRINT "speed factor of" + STR$(SpeedFactor)
PRINT "Press a key to continue..."
WHILE INKEY$ = "": WEND

' Switches to VGA mode
DQBinitVGA

' Plays the animation and automatically loops it
DO
  ' Decodes next frame on layer 2
  DQBplayFLIstep 2

  ' Copies new frame into layer 1, so we can draw on it without problems
  DQBcopyLayer 2, 1

  ' Now the frame has been drawn onto layer 1; you can do your stuff here
  ' ...

  ' Adds delay and copies the frame onto the screen
  DQBwait SpeedFactor
  DQBcopyLayer 1, VIDEO
LOOP WHILE INKEY$ = ""

' The animation stops whenever the user press any key
' Closes the FLI file
DQBcloseFLI

' Ends program
DQBclose
dummy& = SETMEM(66000)
END

*****************************************************************************