       sync on : sync rate 64
       disable escapekey

    ` Reinitialize the plugin if it is needed to change the display mode.
       if screen width() <> 640 or screen height() <> 480 then set display mode 640,480,32 : dxs initialize

    ` Create the background sprite from an image.
       backgroundSprite = dxs create sprite("AdvancedSPRITES.png")
       dxs set sprite tile size backgroundSprite,32,32    ` Cut the sprites into 32x32 pixels tiles.

    ` Create a new empty sprite.
       rotatingSprite = dxs create empty sprite(100,100)
       dxs set sprite center rotatingSprite,50,50         ` Display center at middle of the sprite.
       dxs set sprite scale rotatingSprite,200,200        ` Double the sprite size.

    ` Lock the sprite then write pixels of random color.
       dxs lock sprite rotatingSprite
          for ty = 0 to dxs get sprite texture height(rotatingSprite) - 1
             for tx = 0 to dxs get sprite texture width(rotatingSprite) - 1
                dxs set sprite pixel rotatingSprite,tx,ty,rnd(255),rnd(255),rnd(255),rnd(255)
             next tx
          next ty
       dxs unlock sprite rotatingSprite

    ` Repeat until the user press the escape key.
       repeat

       ` Clear the screen, needed for a proper render.
          cls

       ` Draws the sprite cut into tiles.
          dxs begin sprite render backgroundSprite
             for ty = 0 to dxs get sprite tileset height(backgroundSprite)
                for tx = 0 to dxs get sprite tileset width(backgroundSprite)
                   tileNumber = 1 + ty * dxs get sprite tileset width(backgroundSprite) + tx
                   dxs draw sprite tile backgroundSprite,tileNumber,tx * 32,ty * 32
                next tx
             next ty
          dxs end sprite render backgroundSprite

       ` Increase the sprite rotation angle.
          dxs set sprite angle rotatingSprite,dxs get sprite angle(rotatingSprite) + 1

       ` The mouse is the rotation center.
          dxs set sprite rotation center rotatingSprite,mousex(),mousey()

       ` Update sprite transformation.
          dxs update sprite rotatingSprite

       ` Draws the sprite.
          dxs begin sprite render rotatingSprite
             dxs draw sprite rotatingSprite,mousex(),mousey()
          dxs end sprite render rotatingSprite

       ` Framerate...
          text 10,10,"FPS : " + str$(screen fps())

          sync

       until escapekey() = 1

    ` Delete the sprite when ending the program.
       dxs delete sprite rotatingSprite

       end