REM ***********************************************
REM Title: Draw Text
REM Author: Phaelax
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
// Download demo font at http://zimnox.com/resources/agk/font.php
 
setVirtualResolution(640,480)
 
GLOBAL _Spr_FONT
_Spr_FONT = createSprite(loadImage("font.png"))
setSpriteAnimation(_Spr_FONT, 16, 18, 96)
setSpriteDepth(_Spr_FONT, 2)
 
do
 
        drawText("This is a test.", getPointerX(), getPointerY(), 1, 1)
 
    sync()
loop
 
 
function drawText(s$, x, y, boolCenterX, boolCenterY)
    L = len(s$)
    totalWidth = L*16
    if boolCenterX = 1 then x = x - totalWidth/2
    if boolCenterY = 1 then y = y - 9
    for i = 1 to L
        c = asc(mid(s$,i, 1)) - 31
        setSpriteFrame(_Spr_FONT, c)
        setSpritePosition(_Spr_FONT, x, y)
        inc x, 16
        drawSprite(_Spr_FONT)
    next i
endfunction