PDA

View Full Version : Tileset loading...



Sirius2D
10-07-2008, 12:49 PM
Has anyone considered loaders for Mappy http://www.tilemap.co.uk/mappy.php or Tile Studio http://tilestudio.sourceforge.net/ ? A search through the forum didn't turn up anything...

bullno1
10-07-2008, 03:39 PM
Has anyone considered loaders for Mappy http://www.tilemap.co.uk/mappy.php or Tile Studio http://tilestudio.sourceforge.net/ ? A search through the forum didn't turn up anything...

The editor itself has a built in pseudo tile editor. I recommend it over 3rd party editor since everything is more "integrated".(you know, edit tiles and add edit the game logic at the same time)
Lua's io library is also disabled for security reasons but it's easy to re-enable it.
However, the problem is:
After reading the C++ code, I find no method to add a tile to the game world so that I can bind it to lua. I tried to trace the code to see how the editor add tiles and found out that the process is quite complex(cloning than add to the correct layer...).

It would be nice to be able to add tiles from script. I'm planning to do a roguelike game. It's impossible for now to generate random dungeon.

Seth
10-07-2008, 11:10 PM
Sirius2D: Has anyone considered loaders for Mappy http://www.tilemap.co.uk/mappy.php or Tile Studio http://tilestudio.sourceforge.net/ ? A search through the forum didn't turn up anything...

It surely would be possible... for an early test I wrote an importer that converted the entire Dink Smallwood map and that could be used as an example.

It's in GeneratorDink.cpp, to see it you would have to enable it in the source by uncommenting:


//pItem = m_pMenu->create_item("Utilities/Import from Dink Map");
//m_slot.connect(pItem->sig_clicked(),this, &EntEditor::OnGenerateDink);

in EntEditor.cpp.


bullno1: After reading the C++ code, I find no method to add a tile to the game world so that I can bind it to lua. I tried to trace the code to see how the editor add tiles and found out that the process is quite complex(cloning than add to the correct layer...).

The editor methods are a little complex because of the way it saves everything into undo buffers.

For a straightforward way to add a tilepic from C++ the Dink example shows a way:


pTile = new TilePic;
CL_Vector2 localDestPos = CL_Vector2(x*tileSize, y*tileSize);

pTile->SetPos(localDestPos+vecOffset);

pTile->m_rectSrc = rectSrc;
pTile->m_resourceID = FileNameToID(st.c_str());
if (!GetHashedResourceManager->GetResourceByHashedID(pTile->m_resourceID))
{
throw CL_Error("Unable to locate tilescreen "+st);
}
//figure out where to put it

g_pMapManager->GetActiveMap()->AddTile(pTile);

In the above, "st" is a string that holds the bitmap file name, and rectSrc holds the rect that it should use of the bitmap.

You're right, it isn't possible to add a tilepic from lua yet. I guess I could basically wrap the above code into a simple function that is exported to lua, in general directly manipulating tilepics is a bit limited from script right now.

Another method is to make each wall/etc an "entity".

You can use CreateEntity (http://www.rtsoft.com/novashell/docs/api/files/GlobalScriptFunctionBindings-cpp.html#CreateEntity) to make something. (it does require a script to get it going, just use a simple one)

Next, you would set its Tilepic style visual with Entity:SetImage() (http://www.rtsoft.com/novashell/docs/api/files/EntityBindings-cpp.html#Entity.SetImage).

I actually have been planning to do a random dungeon example and improve the methods to dynamically do things at that time. For instance, I want a way to cut and pace items as a group from lua script - so I can make houses/areas by cut and pasting giant meta-tiles that include many things inside, complete with collision/scripts etc.

These template meta-tiles would be pre-setup in the editor in the exact shape/size that is needed. Still thinking about this...

Sirius2D
10-10-2008, 03:34 PM
Thx for the info and example guys... I'll dust off my compiler and have a look see... :)