#include "Tilengine.bi"

#ifndef NULL
#define NULL cptr(any ptr,0)
#endif

#define SRC_WIDTH	400
#define SRC_HEIGHT	240


dim as TLN_Tilemap tilemap
dim as long frame

' setup engine
TLN_Init(SRC_WIDTH, SRC_HEIGHT, 1,0,0)

' load layer
TLN_SetLoadPath ("../assets/sonic")
tilemap = TLN_LoadTilemap ("Sonic_md_fg1.tmx", NULL)
	
' setup the layer
TLN_SetLayer(0, NULL, tilemap)
TLN_SetBGColor(32,32,128)

' main loop
TLN_CreateWindow(NULL, 0)
while TLN_ProcessWindow()
  ' scroll the layer, one pixel per frame */
  TLN_SetLayerPosition (0, frame, 0)
  ' render to the window 
  TLN_DrawFrame(frame)
  frame+=1
wend

' release resources
TLN_DeleteTilemap(tilemap)
TLN_Deinit()
