Author Topic: can you help me with tiles?  (Read 67 times)

pielago

  • Newcomer
  • *
  • Posts: 13
    • View Profile
can you help me with tiles?
« on: 05. September 2017, 23:54:02 »
looking at the documentation I saw tilesets but I am not able to work them!
I see

loadtileset(filename, lines,rows,string )
tileset( image, lines,rows,string )

I tried to do it but the string? got me confused
can someone give me a small example how to properly use it
hope  someone respond  and thanks so much!

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 574
    • View Profile
    • Home of EGSL
Re: can you help me with tiles?
« Reply #1 on: 10. September 2017, 09:56:12 »
It's similar to the bitmapfont function.

Let's assume you have an image with two tiles in it. Now you can load your image with
Code: [Select]
mytile=loadtileset ("image.png",1,2,"ab") or if you already loaded the image
Code: [Select]
mytile=tileset(image,1,2,"ab")
The string is similar to the fontface of a bitmapfont, so if you want to draw the first tile you do the following:
Code: [Select]
drawtile (0, 0, "a", mytile)the second tile
Code: [Select]
drawtile (0, 0, "b", mytile)or a longer line (with both tiles)
Code: [Select]
drawtile (0, 0, "aaabbaabbbbaaaabbaaa", mytile)
It's not very nice as you can see, I recommend it only for background drawing where no tiles are changing because string manipulation is slower than using numbers. (And of course you are limited to a string which means if you are using the alphabet you can handle with upper and lower case 52 tiles.)
Best regards,
Cybermonkey