Try this. I've tweaked it to work with 256 frames, using a variable to make it easier to alter. Tried it with the image and it works fine.
setvirtualresolution(640,480)
setvsync(1)
type tile
spriteID
`********************************
image ` changed from properties to a more relevant label
endtype
dim map[19,14] as tile
grid=32
maxframes=256
backdroptiles=loadimage("tileset.png")
gosub init
`*****************************
current=1
cursor=createsprite(backdroptiles)
setspriteanimation(cursor,32,32,maxframes)
setspritedepth(cursor,0)
do
gosub control
`*****************************
setspriteposition(cursor,mx*grid,my*grid)
Sync()
loop
control:
mx=( floor(getpointerx()/grid) )
my=( floor(getpointery()/grid) )
print(mx)
print(my)
if mx>=0 and my>=0
hit=map[mx,my].spriteID
print(map[mx,my].spriteID)
endif
print(hit)
print(GetManagedSpriteCount())
if getpointerstate()=1
if mx>=0 and mx<20 and my>=0 and my<15
if getspriteexists(hit)=0
createsprite(hit,0)
setspritesize(hit,32,32)
setspriteposition(hit,mx*grid,my*grid)
`****************************************
setspriteimage(hit,backdroptiles)
setspriteanimation(hit,32,32,maxframes)
setspriteframe(hit,current)
map[mx,my].image=current
endif
`*************************************
if getspriteexists(hit)=1
` ***************************************
`setspritecolor(hit,0,255,0,255)
setspriteframe(hit,current)
map[mx,my].image=current
endif
endif
endif
if GetRawMouseRightState()=1
if mx>=0 and mx<20 and my>=0 and my<15
if getspriteexists(hit)=1
deletesprite(hit)
map[mx,my].image=0
endif
endif
endif
`***************************
if getrawkeypressed(187)=1
current=current+1
if current>maxframes
current=1
endif
setspriteframe(cursor,current)
endif
`***************************
if getrawkeypressed(189)=1
current=current-1
if current<=0
current=maxframes
endif
setspriteframe(cursor,current)
endif
if getrawkeypressed(32)=1
gosub save
endif
if getrawkeypressed(76)=1
gosub load
endif
if getrawkeypressed(67)=1
gosub init
endif
return
init:
count=0
for x=0 to 19
for y=0 to 14
if getspriteexists(map[x,y].spriteID)=1
deletesprite(map[x,y].spriteID)
endif
count=count+1
createsprite(10000+count,0)
setspritesize(10000+count,31,31)
setspriteposition(10000+count,x*grid,y*grid)
setspritecolor(10000+count,100,100,100,80)
map[x,y].spriteID=10000+count
map[x,y].image=0
next y
next x
` get overlay image
if getspriteexists(1)=0
render()
getimage(1,0,0,640,480)
clearscreen()
createsprite(1,1)
setspritesize(1,640,480)
endif
for n=10000 to 10000+count
deletesprite(n)
next n
return
save:
opentowrite(1,"map.dat")
for x=0 to 19
for y=0 to 14
writestring(1,str(map[x,y].spriteID))
writestring(1,str(map[x,y].image))
next y
next x
closefile(1)
print("Map saved")
sync()
sleep(200)
return
load:
opentoread(1,"map.dat")
for x=0 to 19
for y=0 to 14
if getspriteexists(map[x,y].spriteID)=1
deletesprite(map[x,y].spriteID)
endif
map[x,y].spriteID=val(readstring(1))
map[x,y].image=val(readstring(1))
` ****************************************
if map[x,y].image>0
createsprite(map[x,y].spriteID,0)
setspritesize(map[x,y].spriteID,32,32)
setspriteposition(map[x,y].spriteID,x*grid,y*grid)
`*************************************
setspriteimage(map[x,y].spriteID,backdroptiles)
setspriteanimation(map[x,y].spriteID,32,32,8)
`if map[x,y].image=1
`setspritecolor(map[x,y].spriteID,0,255,0,255)
`**********************************
setspriteframe(map[x,y].spriteID,map[x,y].image)
`endif
endif
next y
next x
closefile(1)
print("Map loaded")
sync()
sleep(200)
return