Alright, I did the second option you have there, as the amount of tiles on the map are decided by the user.
It says these two methods/fields lines are null though:
I am oblivious as to why this isn't working.. No matter what I do those lines are always null..
SuperStrict Graphics 640,480,0,60 Const tsx:Int=32 'width of each tile Const tsy:Int=32 'height of each tile Const frms:Int=15 '# of frames in the tile set Const timg$="samples\tileset1.png" 'the tile set image Const tnumx:Int=20 '# of tiles across on your map Const tnumy:Int=15 '# of tiles down on your map Local mx:Int,my:Int 'mouse x/y Local ctile:Int 'currently selected tile Global map:tilemap=tilemap.Create(tsx,tsy,timg$,tnumx,tnumy,frms) SetColor(255,255,255) While Not KeyHit(KEY_ESCAPE) mx=MouseX()/tsx*tsx my=MouseY()/tsy*tsy map.Draw(tnumx,tnumy,tsx,tsy,ctile) If KeyHit(KEY_RIGHT) ctile:+1 EndIf If KeyHit(KEY_LEFT) ctile:-1 EndIf If ctile>frms-1 Then ctile=0 If ctile<0 Then ctile=14 DrawImage(map.tset,mx,my,ctile) Flip;Cls Wend End Type tilemap Field tset:TImage,tiles:tile[,] Method Draw(tnumx:Int,tnumy:Int,tsx:Int,tsy:Int,ctile:Int) For Local x:Int=1 To tnumx For Local y:Int=1 To tnumy tiles[x,y].Draw(x*tsx,y*tsy) Next Next If MouseDown(MOUSE_LEFT) tiles[MouseX()/tsx,MouseY()/tsy].tfrm=ctile EndIf End Method Function Create:tilemap(tsx:Int,tsy:Int,timg$,tnumx:Int,tnumy:Int,frms:Int) Local tm:tilemap=New tilemap tm.tset=LoadAnimImage(timg$,tsx,tsy,0,frms) tm.tiles=New tile[tnumx,tnumy] Return tm For Local x:Int=1 To tnumx For Local y:Int=1 To tnumy tm.tiles[x,y].tfrm=0 Next Next End Function End Type Type tile Field tfrm:Int Method Draw(x:Int,y:Int) SetColor(255,255,255) DrawImage(map.tset,x,y,tfrm) End Method End Type
It says these two methods/fields lines are null though:
tiles[x,y].Draw(x*tsx,y*tsy) and tiles[MouseX()/tsx,MouseY()/tsy].tfrm=ctile
I am oblivious as to why this isn't working.. No matter what I do those lines are always null..