Theopholis' Isometric Tile Editor/One day a game

Showcase your libraries, tools and other projects that help your fellow love users.
Theopholis
Prole
Posts: 8
Joined: Fri Jan 17, 2014 9:55 am

Theopholis' Isometric Tile Editor/One day a game

Post by Theopholis »

Hello!

I'm new to both LÖVE and Lua, these forums, and programming of any kind; but after a couple of days with the docs open I managed to put this together.

Note: Get the Latest Version Here
isoEditor.love
(8.18 KiB) Downloaded 248 times
Surprise! It's yet another Isometric Tile Editor! I'm sure you guys have seen plenty of these, and mine's nothing special. I plan to develop it into a game over time, but thought I'd work in smaller iterations while I figured out what I was doing. I think I'm doing pretty well so far, but would love :rofl: some feedback from people who knew a thing or two about anything.

Here's the text of the readme file inside package.

Code: Select all

Isometric Tile editor 1.0

It has 2 tiles: grass and dirt. You can change grass to dirt, but not dirt to grass.
The tiles' heights can be adjusted. Can save and load maps (buggy).

Keys:
"h" switches to height changing
"d" switches to tile changing

Note, you will need to run the program from a terminal to use these
"Ctrl l" loads a map. map "problem" is included as an example
"Ctrl s" saves a map
"Ctrl n" makes a new map.

Mouse:
Left Click performs tile/height change
Right click and drag to pan camera
Mouse Wheel up/down to zoom in/out, centered on the mouse position

Problems I'm having:
I've left notes in the code, and would love it if people dug into it
and looked and them in context. But, here's a summary.

-Camera Panning is jittery if camera.speed > 1
-Height changing a tile will move to a different tile without a new click.
	(I think I know how to fix this, but haven't yet! Comments still appreciated)
-Map saving/loading only works if the program is closed between uses
-Draw order is funny for some non-generated tiles.
-Coordinate Math may have extra bits...?

Stuff I think is okay, but could use evaluation:
-Input handling
-Save formats
-Use of functions, areas where code could be reused better
-General Everythingness
That's about all I can think of. Feel free to ask questions, give advice, suggest cool things, or print out and mark up my code with a red pen so you can mail it to me. Whatever works for you. ;)

Thanks!
Last edited by Theopholis on Wed Jan 22, 2014 1:29 am, edited 2 times in total.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Sheepolution »

Welcome to the forum! Your isometric tile editor looks awesome! But, this board is for 'Support and Development'.
I suggest you make these kind of threads in 'Projects and Demos'.

But seriously, the tile editor looks great.
Theopholis
Prole
Posts: 8
Joined: Fri Jan 17, 2014 9:55 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Theopholis »

Ahhhhh. I knew it. I figured, "I need support with the development of a project to make a demo", and then just took a shot in the dark. Thanks for letting me know! I'll see if I can move this...

Edit: Moved! Thank you to the mod who did it :)
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Germanunkol »

This is really neat! Especially considering you're new here - great work!

I'm not too fond of the amount the height changes when in height changing mode - I find it relatively difficult to adjust the height to how much I want (it moved up too quickly). Is it possible that the height changing is not checking for the zoom level yet? If so, and it depends on the amount the mouse is moved up or down, then that would explain why it moves up way too far when I just move the mouse up a little.

To your code:
It's incredibly clean and well structured, from what i've seen so far.
The drawing function might not be ideal for the game, yet. You're iterating over the map for each frame - which is totally fine for coding a level editor. However, when drawing so many similar images, where only one or two change every now and then, it might be better to use sprite batches. These are neat because they drastically reduce the number of draw-calls which speeds up the game.
For the editor, it's basically up to you if you use them or not, but when you use the maps in a game, I think you should definately use sprite batches.

Btw, I got this when I tried to load a map:
(To reproduce: run the .love, play around with the height map and painting tools, then press CTRL+L)
Image

Edit: P.S: No need to give your files to google. The board has a very neat upload feature which you can use when posting anything. Just in case you hadn't seen it yet...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Theopholis
Prole
Posts: 8
Joined: Fri Jan 17, 2014 9:55 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Theopholis »

You're right, the height changing does not seem to be adjusting for the zoom level. I'll fix that!
To be honest, the height changes were just something I threw in to see what I could do, and to help me determine how I should structure the map data, when a tile could have multiple variables needed inside of it. I do like the terrain that can be made with it though.

Those sprite batch functions look like they could be really helpful. It looks like I would be able to write all the tiles to it, and then only update it when changes are made to the map...right? I'll have to read the whole thing, but it looks cool.

I actually restructured the screen.DrawMap() function yesterday. It's condensed, but still wastes all those draw resources. It looks like this now.

Code: Select all

function screen.drawMap()
	for ykey,yvalue in ipairs(coord.sortPairsIn(map)) do
		for xkey,xvalue in ipairs(coord.sortPairsIn(map[yvalue])) do
			tile = map[yvalue][xvalue].tile
			local x,y = coord.Grid2Iso(xvalue,yvalue)
			love.graphics.draw(tiles[tile],x,y-map[yvalue][xvalue].height)
		end
	end
end

function coord.sortPairsIn(t)
	local ordered = {}
	local i = 0
	local n = 0
	while i<t.ln do
		if t[n] ~= nil then
			table.insert(ordered,n)
			i = i+1
		end
		if t[-n] ~= nil then
			table.insert(ordered,1,-n)
			i = i+1
		end
		n = n+1
	end
	return ordered
end
It turns out that pairs() spits out the table entries in the order of their unique ids, which is unreliable, ipairs() can't skip over a nil, and table.sort() just didn't work in this case (I can't remember why now ...) so I had to write my own sorting function to make this work. It's currently skipping over it's last positive value when it finds it's first negative value though. I'll be fixing that today, I hope. Still, it currently allows for islands to be drawn without declaring all the empty space, which is pretty cool, I think.

I get problems like that with the loader all the time too. I'm fixing it...but can't seem to get it to close a file after saving. The program needs to be shut down before the files are actually written. Meaning that you can only load files you saved at least one program-run ago. I think that structure of the save-files is going to change a ton over time so I don't want to devote a ton of time to perfecting the file handler right now. On the other hand, I can't recreate the error (using a previously saved file, all just-saved files won't work still), so maybe I accidentally fixed it.

I put the file up as an attachment. I hadn't noticed the upload hiding down there with the options tab.

Thanks for downloading and taking a look Germanunkol! I appreciate it a lot!
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by ArchAngel075 »

absolutely amazing so far, i was suprised at the smooth tile height changing...I was expecting it to be a static sort (like a grid on the z axis)

I noticed trying to change the height of nothing will crash :
tool.lua : line 52

Also drawing the west side of tiles is abit incorrect as it would not properly hide tiles behind one another.

But nitpicking is nitpicking...

So in the end its great and im probably going to end up using this in the future for some incomplete project.
Theopholis
Prole
Posts: 8
Joined: Fri Jan 17, 2014 9:55 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Theopholis »

@ArchAngel075 It would be pretty cool to see people using something that I made someday. At this point it wouldn't be too useful of course.

I think I've more or less cleared out all the bugs mentioned above by now, other than a few issues with the mouse input affecting the camera and height control that I can't seem to figure out (and save/load, but no point in fixing that until the other layers are in place). Everything is using the SpriteBatches now too, which is pretty cool, even if it makes no noticeable difference right now.

Oh yeah, and the reason some tiles were being missed before was because my coord.sortPairsIn() function was counting both 0 and -0 as different tiles.
Negative zero! Ha! :awesome:
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by ArchAngel075 »

a great request for a feature :
Snap to Grid on Z-layer

When moving an tile on the Z level have it , instead of that smooth change, snap to a grid. This makes having to carefully place many many tiles on the same height a easy task rather than a pain.

--

Not part of the request :

May i ask for the upcoming features list or something like that? Would be great to know what we could be expecting and what we should not request?
Theopholis
Prole
Posts: 8
Joined: Fri Jan 17, 2014 9:55 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by Theopholis »

An upcoming features list...hmm...I'm just kind of making stuff up as I go.

Well, today I plan on adding a proper Z layer to the data structure. Right now the tiles are stored in a map[y][x].variousDataThings matrix, and I'm going to make it map[z][y][x].variousDataThings, which will allow for multiple layers of tiles. I'm going to subdivide the Z axis into 4 parts though, so that the "smooth" height adjust becomes an adjustment between 1/4, 2/4, 3/4 and 4/4 blocks within a cubic tile space.

I think each Z layer will be it's own spriteBatch, which will allow for one layer at a time to be dynamically updated, if say a player is on that level, and the rest to be bound, and saving GPU resources.

Once that's done, I'd like to make a system for toggling layers on and off, so that you can see behind walls, and a player can be hidden, but not lost. Probably with the scroll wheel, as I see it being more useful than zoom, since I generally just set things to the zoom level I like and stay there.

With the Z axis set up, I should be able to develop some kind of lighting system too, and maybe even a dynamic line of sight kind of thing that uses it. I think that would be pretty cool.

I'm also going to split the tile tops from the tile walls, so that different combinations can be put together, different wall heights can easily be used, walls can be individually lit, and less GPU resources are wasted on overlapping/totally covered tiles. Although, it would still be up to the level designer to actually use the feature, maybe, I guess.

Oh, and I'd really like to set up map rotation. Which should probably just require a reversed sort function...but I'm scared I'll ruin everything so I'm going to wait a little while longer ;)

You know, and then some tools for editing, some tiles, a GUI of some sort, proper save-file structure, and then some ways to make it work inside a game.
But, again, I'm just making stuff up! You're welcome to suggest features, though I think this will always be an editor/thing that would require some alterations to be used well with any specific game, as the needs of each game are different. But Lua and LÖVE are both so flexible and easy to use that it should never be too much of a problem.
Last edited by Theopholis on Tue Jan 21, 2014 4:59 am, edited 1 time in total.
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Theopholis' Isometric Tile Editor/One day a game

Post by ArchAngel075 »

its hardly ever that i see such a nicely planned project in a nicely structured post XD.

Im really looking forward to the change of the mouse-scroll to work with layers.
Although im actually wanting to make a "pallet" or whatever you call it, say you hold down the mouse wheel and a circular shaped GUI appears at the spot of mouse-cursor. Then you can choose tools/options inside the pallet. Perhaps make it even customizable with what options users want to see...

Well thatl eventually come when I develop a map maker for my current project, though if you'd want such a tool I'd be happy to try?

It sure sounds hard having to wrap around isometric stuff, i think ill never get my brain to understand isometric drawing etc... so goodluck again!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 3 guests