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

pielago

  • Guest
can you help me with tiles?
« on: September 05, 2017, 09:54:02 PM »
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
  • *****
  • Posts: 0
Re: can you help me with tiles?
« Reply #1 on: September 10, 2017, 07:56:12 AM »
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.)

pielago

  • Guest
Re: can you help me with tiles?
« Reply #2 on: October 03, 2017, 10:33:20 PM »
thank you so much ill practice the tiles...