Here is a set of 3 functions which read/print/capture-to-image tiles from the RPGToolkit tileset format (*.TST)
The function program is attached and bellow is an example to show you how to use the functions. (Also gives you a peak at my board editor for my 2D RPG Designer
`Tileset Functions Example
#include "TileSetFunc.dba"
`these variables are essential to the workings of the functions
dim R(15,32,32)
dim G(15,32,32)
dim B(15,32,32)
cls 0
sync on
Size=ReadTileset("tileset.tst",15) : `last number must be less than/equal to the first number in the R/G/B arrays
for tios=3 to 7
DrawTiles(0,(32*(tios-3)),tios,tios,Size) : `Draws tiles to the screen @ the specific locations
next tios
set cursor 0,32*((tios+1)-3)
print "Tiles 3 to 7 have been drawn using DrawTiles()"
Print "<press any key>"
suspend for key
cls 0
GetTile(3,1) : `Makes a tile an Image to be used with sprites
cls 0
get image 2,0,0,31,31
`get image 3,0,0,screen width(),screen height()
img#=1
do
`cls 0
`paste image 3,0,0,1
tilex=mousex()/32
tiley=mousey()/32
key=scancode()
if key>=2 and key<=11
if key=11 then key=1
get image 13,0,0,screen width(),screen height()
cls 0
GetTile(key-1,key)
cls 0
paste image 13,0,0,1
img#=key
endif
if keystate(48)=1
img#=12
endif
if mouseclick()=1
if img#=12
ink 0,0
box tilex*32,tiley*32,(tilex*32)+32,(tiley*32)+32
ink rgb(255,255,255),0
else
paste image img#,tilex*32,tiley*32,trans
endif
endif
` get image 3,0,0,screen width(),screen height()
sync
loop
The three functions are:
ReturnVar=ReadTileset(filename$,#ofTiles2Read)
Reads tiles from the specified file (
filename$) from tile 0 to
#ofTiles2Read. The
ReturnVar is the tile size (x and y) for the tileset (generally returns 32 if you are using Tookit Tilesets over v2.0).
DrawTiles(xpos,ypos,First2Draw,Last2Draw,SizeofTile)
This draws the tiles that have been read to the screen.
xpos and
ypos are the drawing start points. The function will draw tile
First2Draw to tile
Last2Draw.
SizeofTile is the
ReturnVar from the previous function.
GetTile(Tile#,Image#)
Gets the specified tile (
Tile#) and set it as the specified image (
Image#).
Enjoy!
[edit] Tested in DBC only. I don't know if it'll work in DBPro, but anyone is welcome to try... oh, and if there are any suggestions for improvement or any additional functions you want to see, please don't hessitate to say so.
Dragael Software
Current Project: Nothing worth mentioning