Retrogamecoding(.org) > EGSL

can you help me with tiles?

(1/1)

pielago:
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:
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: ---mytile=loadtileset ("image.png",1,2,"ab")
--- End code ---
or if you already loaded the image

--- Code: ---mytile=tileset(image,1,2,"ab")
--- End code ---

The string is similar to the fontface of a bitmapfont, so if you want to draw the first tile you do the following:

--- Code: ---drawtile (0, 0, "a", mytile)
--- End code ---
the second tile

--- Code: ---drawtile (0, 0, "b", mytile)
--- End code ---
or a longer line (with both tiles)

--- Code: ---drawtile (0, 0, "aaabbaabbbbaaaabbaaa", mytile)
--- End code ---

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:
thank you so much ill practice the tiles...

Navigation

[0] Message Index

Go to full version