For simple animation such as card games etc., quite acceptable results can be obtained in the animation of simple objects without using a double-buffered screen. The trick is to use an image as a kind of "poor man's drawing buffer", do all drawing to it, and then draw the buffer image to the window in a step analogous to FlipBuffers() if you were using a screen.
Here is a basic example:
Code: Select all
Declare.l MouseCollision()
Global xoffset.l,yoffset.l,tilex,tiley,grabbing
Enumeration
  #window
  #cardimage
  #bufferimage
  #bkgimage
EndEnumeration
CreateImage(#cardimage,70,96)
CreateImage(#bkgimage,640,480)
StartDrawing(ImageOutput(#bkgimage))
  Box(0,0,640,480,RGB(170,120,0))
StopDrawing()
CreateImage(#bufferimage,640,480)
StartDrawing(ImageOutput(#cardimage))
  Box(0,0,70,96,#White)
  DrawText(20,40,"Card",#Red,#White)
StopDrawing()
OpenWindow(#window,0,0,640,480,"Simple Screenless Animation Demo",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
tilex = 124
tiley = 124
Quit = 0
Repeat
  ev=WindowEvent()
  If ev=#WM_LBUTTONDOWN And MouseCollision()
    xoffset=WindowMouseX(#window)-tilex
    yoffset=WindowMouseY(#window)-tiley
    grabbing = #True
  EndIf
  If ev = #WM_LBUTTONUP
    grabbing=#False
   EndIf
  If Grabbing
    tilex=WindowMouseX(#window)-xoffset
    tiley=WindowMouseY(#window)-yoffset
  EndIf
  StartDrawing(ImageOutput(#bufferimage))
    DrawImage(ImageID(#bkgimage),0,0)
    DrawImage(ImageID(#cardimage),tilex,tiley)
  StopDrawing()
  StartDrawing(WindowOutput(#window))
    DrawImage(ImageID(#bufferimage),0,0)
  StopDrawing()
  Delay(1)
Until ev=#PB_Event_CloseWindow Or Quit = 1
End
Procedure.l MouseCollision()
  If WindowMouseX(#window)>tilex And WindowMouseX(#window)<tilex+70
    If WindowMouseY(#window)>tiley And WindowMouseY(#window) < tiley+96
      ProcedureReturn #True
    Else
      ProcedureReturn #False
    EndIf
  EndIf
EndProcedure 



