powerful yes - but very hard to delete
ummm... are they?
Strict Type TTile Field X:Int Field Y:Int End Type Type TMapLayer Field tiles:TTile [][] Field ID:Int Function Free(Layer:TMapLayer) For Local x:TTile[] = EachIn Layer.Tiles For Local Y:TTile = EachIn x y = Null Next Next Layer = Null FlushMem End Function Function Create:TMapLayer(Width:Int, Height:Int, ID:Int) Local tempLayer:TMapLayer = New TMapLayer tempLayer.Tiles = tempLayer.Tiles[..Width] For Local h:TTile[] = EachIn tempLayer.Tiles h = h[..Height] Next For Local x:Int = 0 To width -1 For Local Y:Int = 0 To Height - 1 tempLayer.tiles[x][y] = New TTile Next Next Return tempLayer End Function End Type Type TMap Field Name:String Field Tileset:TImage Field Layers:TMapLayer[] Field Width:Int Field Height:Int Method AddLayer(ID:Int) Layers = Layers[..Len(Layers)+1] Layers[Len(Layers)] = TMapLayer.Create(Width, Height, ID) End Method Function Free(Map:TMap) For Local tempLayer:TMapLayer = EachIn Map.Layers tempLayer.Free(tempLayer) Next Map = Null FlushMem End Function Function Create:TMap(Name:String, TilesetFile:String, Width:Int, Height:Int) Local tempMap : TMap = New TMap tempMap.Name = Name tempMap.TileSet = LoadImage(TilesetFile) tempMap.Width = Width tempMap.Height = Height tempMap.AddLayer(0) Return tempMap End Function End Type