RPG design help

What software is compatible with the program Tiled? Been trying to make an 3D or 2d RPG for pc.

Defold can work well with Tiled generated maps to make RPGs like Pokemon or Final Fantasy. Have you gone through any of the Defold tutorials yet?

3 Likes

Tiled has support for defold, as explained here Tiled map editor export to Defold (SOLVED) :

Go to Preferences in Tiled then plugins and enable the libdefold.dylib by ticking it.
You can then export as Defold *.tilemap format

2 Likes

it’s quite easy also to read the json Tiled can export without any plugin - and then create the tilemap inside Defold runtime (even if this way you need to have an already compatible tileset/tilesource pair in your project - with correct dimensions (must be equal or bigger) and layer names)

Doing that you can use also object layers - in order to create game objects with factories (using also custom properties)

This is a sample code to fill Defold tileset reading content from Tiled json (I cut it from my current game - it’s possible something won’t compile - I can have missed an end or more and it has references to my variables - but I think could give you an idea how to proceed if you want to check this way)

function createleveltilemap(self,filename)
	local jsonstring = sys.load_resource(filename)
	local data = json.decode(jsonstring)
	local width = data.width
	local height = data.height
	local tile_height=data.tileheight
	local tile_width=data.tilewidth
	local layers= data["layers"]

	level_realmaxx=width*tile_width

	for k, v in pairs(layers) do
		local layer=v
		local name=layer.name
		local tiles=layer.data
		local objects=layer.objects
		if tiles then
			local hname=hash(name)
			local x=0
			local y=0
			for idx, index in ipairs(tiles) do
				if index==-1 then
				else
					tilemap.set_tile("map#level",hname,x+1,height-y,index)
				end
				x=x+1
				if x == width then
					x=0
					y=y+1
				end				
			end
	elseif objects then
			for idx, obj in ipairs(objects) do
				local name=obj.name
				local type=obj.type
				local x=obj.x
				local y=obj.y
				local w=obj.width
				local h=obj.height
				local health=-1
				local activationway=1
				if obj.properties then
					for p, prop in ipairs(obj.properties) do
						if prop.name=="health" then
							health=tonumber(prop.value)
						elseif prop.name=="activation" then
							activationway=tonumber(prop.value)
						end
					end
				end
				if type == "hero" then
					local pos = vmath.vector3(x+w/2, height*tile_height-(y+h/2), 0)
					go.set_position(pos,"/level/player")
				elseif type == "villain" then
					local pos = vmath.vector3(x+w/2, height*tile_height-(y+h/2), 0)
					local villain=factory.create("#enemiesfactory",pos,nil,{id=1+#villains,maxhealth=health,name=hash(name),activationway=activationway,reachpos=0+#villains})
					table.insert(villains,villain)
				end
			end
		end
	end
 end

end

4 Likes