RetroBASIC ReadOnly Archive
-- shows how to load an image and turn that into a spriterequire "scancodes"knight ={}win = openwindow ("Simple Sprite Example",-1,-1,800,600)setactivewindow (win)setframetimer (100)image = loadimage ("media/sprite.bmp")knight.image = createsprite (image)freeimage (image)image = loadimage ("media/grass.bmp")grass = createsprite (image)freeimage (image)knight.x=windowwidth()/2knight.y=windowheight()/2textsize (1)--main loop starts here:repeatkey=getkey()clearwindow()if keystate (SCANCODE_RIGHT) then knight.x=knight.x+1endif keystate (SCANCODE_LEFT) then knight.x=knight.x-1endif keystate (SCANCODE_UP) then knight.y=knight.y-1endif keystate (SCANCODE_DOWN) then knight.y=knight.y+1endfor i = 0, windowwidth(), spritewidth (grass) do for j = 0, windowheight(), spriteheight (grass) do drawsprite (grass,i,j,1,1,0,false,false) endenddrawsprite (knight.image,knight.x,knight.y,1,1,0,false,false)color (255,255,255,255)texttype (1)drawtext ("Cursor keys to move knight, ESC to quit",0,0)texttype (2)drawtext ("Cursor keys to move knight, ESC to quit",0,20)sync()until key == SCANCODE_ESCAPE--here all comes to an end...freesprite (knight.image)freesprite (grass)closewindow (win)closeapplication()
knight.x=int (windowwidth()/2)knight.y=int (windowheight()/2)