## Completely Lua/Love2D based map editor and player

Showcase your libraries, tools and other projects that help your fellow love users.
pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Completely Lua/Love2D based map editor and player

Hey all-
I'm working on a map editor and map class that would load right into Lua/Love2D using a variety of tools. The end idea will make it really simple to edit a map, save it, load it into a game and display it anyway you feel fit. It will also allow the editor to be "in game" so that you can, if you wish, switch to edit a map while playing, save it, return to the game and see the results right away.

It's still in the foundation stage (the editor is about 35% done, the actual map object to be used in the game 100% done). It will allow you to create and load objects for anything you need in the game that's not tile based.

A quick question:
For objects, would you rather it was just a simple table that's returned with a series of values telling you what the object is and you load/create however you want, or would you rather have a basic object class that you inherit from, and the map editor knows to use/load these classes based on a directory structure?

One is loose and pretty much leaves implementation up to you. The other is strict and OO, but can be very handy.

The map object (display) will also have a series of layer classes, with their own camera per each layer, to make it crazy simple to do parallax scrolling. Same with setting the opacity. Objects themselves can easily move between layers, so that you can have that cool SNES effect that was used in Super Castlevania and Super Mario World (hit a switch, go into the background layer).

Will post more when I have a demo/etc. for feedback.

micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

### Re: Completely Lua/Love2D based map editor and player

I don't want to turn down your motivation, but there is already a solution for this: The Tiled map editor together with the LÖVE-Library Advanced Tiled Loader.

The novelty I see in your plan, is the option to edit a map ingame. So I hope you make this feature really useful.

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

First off, I know about both. Second off- I thought the Advanced Tiled Map Loader was useless and slow for the stuff I wanted to do with my own game. I even made my own Tiled Map Loader, since it was crazy simple based on the Tiled->Lua export. Like, insanely simple, and I could get it to do what I wanted to with far less coding then if I went the same route with the Advanced Tiled Map Loader. It felt like, using the ATML, that I was constantly dancing around the code to get it to do what I needed to do. I'm sure if you're making a simple game it's great and awesome. But for any deal of complexity, it can be very limiting. Esp when it comes to placing objects.

The thing is though, there "isn't" already a solution for this, since it's not done in Love2d or Lua, it's done in Java. That's like saying, "there is already a solution for this" when talking about Love2d and pointing out some GameMaker or something. It's a different beast all together.

I think, really, if something is native to the language you're using, and built around that language, it becomes less limiting and more useful, since it's built with that language in mind. Tiled is awesome, no doubt, but it can be limiting in some aspects, even with using the export to Lua and building your own loader based on that. And that's because Tiled was built in Java, but built in a way to make it portable to other engines/etc. And in doing so, even though it's open and extensible, it's still limiting. For example, I can't edit a Lua script for an object directly inside of Tiled. I need to do several steps to get an object related to a Lua script- I need to create the object, I need to set a value to that object to identify it, then in my code I need to check for that value, and have it perform the related script.

If it's in Lua, I won't need to do all of that. I can just easily relate object to script (or even have the map editor "know" my Lua tables/classes/etc for an object, and have it load that object into the map editor itself, and then drag and drop these things around...).

The other side of the coin is that this will be Open Source, and this if done correctly (which it will- think extensible building blocks, or how some web CMS's approach modularity) it can easily be extendable in all sorts of different ways, allowing for someone in the community to build upon it without too much difficulty.

Jeeper
Party member
Posts: 546
Joined: Tue Mar 12, 2013 7:11 pm

### Re: Completely Lua/Love2D based map editor and player

pauljessup wrote:First off, I know about both. Second off- I thought the Advanced Tiled Map Loader was useless and slow for the stuff I wanted to do with my own game. I even made my own Tiled Map Loader, since it was crazy simple based on the Tiled->Lua export. Like, insanely simple, and I could get it to do what I wanted to with far less coding then if I went the same route with the Advanced Tiled Map Loader. It felt like, using the ATML, that I was constantly dancing around the code to get it to do what I needed to do. I'm sure if you're making a simple game it's great and awesome. But for any deal of complexity, it can be very limiting. Esp when it comes to placing objects.

The thing is though, there "isn't" already a solution for this, since it's not done in Love2d or Lua, it's done in Java. That's like saying, "there is already a solution for this" when talking about Love2d and pointing out some GameMaker or something. It's a different beast all together.

I think, really, if something is native to the language you're using, and built around that language, it becomes less limiting and more useful, since it's built with that language in mind. Tiled is awesome, no doubt, but it can be limiting in some aspects, even with using the export to Lua and building your own loader based on that. And that's because Tiled was built in Java, but built in a way to make it portable to other engines/etc. And in doing so, even though it's open and extensible, it's still limiting. For example, I can't edit a Lua script for an object directly inside of Tiled. I need to do several steps to get an object related to a Lua script- I need to create the object, I need to set a value to that object to identify it, then in my code I need to check for that value, and have it perform the related script.

If it's in Lua, I won't need to do all of that. I can just easily relate object to script (or even have the map editor "know" my Lua tables/classes/etc for an object, and have it load that object into the map editor itself, and then drag and drop these things around...).

The other side of the coin is that this will be Open Source, and this if done correctly (which it will- think extensible building blocks, or how some web CMS's approach modularity) it can easily be extendable in all sorts of different ways, allowing for someone in the community to build upon it without too much difficulty.
I have a huge grudge against ATL and if you would make something better then you have earned my eternal love.

Keep up the good work!

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

Hey thanks man

Once I start getting the editor itself out of the "OMG work damn you!" phase I'll post some githubbery.

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

One idea I'm working on right now, is to have the map editor load map objects that inherit from a base object....and these are simple:

function load

function draw

function update

objects that you can override each function if you want, or use the defaults if you want. This allows the map editor to place objects in game and then draw them looking exactly as they would look like in game. You can just drag and drop some coins, a monster, etc. based on the scripts you made, and there it is. I'll also have some pre-made objects you can inherit from for things like collision, etc.

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

Long time, no see, I know, I know...

Anyway, a quick update. Here's an example of how the map engine will work

Code: Select all

greentea=require("greentea")

function love.load()
greentea:new_map({	name="test",
height=600, width=600,
camera=gt_camera({x=16, y=16, height=600, width=600}),
tileset=gt_tileset({id="new",
image="game/maps/test.png",
tile_height=8,
tile_width=8
})
})
greentea:add_layer({id="ground",
opacity=255,
default_tile=2
})

greentea:add_layer({id="above",
opacity=255,
type="parallax",
default_tile=5,
values={scroll_x=0, scroll_y=1}
})
end

function love.update(dt)
--always need this--
greentea:update(dt)
end

function love.draw()
--always need this--
greentea:draw()
end

People that have used Drupal and Drupal Forms API- the creation of a map should look familiar!

Anyway, happy that the plugin abilities are working too- that type="parallax" is from a test plugin I made that allows a layer with that type to parallax scroll.

Should have a git bit soon enough.

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

Here's the basic plugin:

Code: Select all

local plax=Class{}
plax:include(gt_layer)

function plax:init(layer_info)
gt_layer.init(self, layer_info)
end

function plax:update(dt)
gt_layer.update(self, dt)
self:scroll(self.values.scroll_x, self.values.scroll_y)
end

return plax
It's in a file called parallax.lua, which is where it gets it's type from.

Also, calling it Greentea...have a logo for it and junk.
Attachments
greentealogo.png (5.56 KiB) Viewed 8648 times

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Re: Completely Lua/Love2D based map editor and player

& of course, the editor will be called with greentea:editor() and it will load the current map into an editor. Also working on a file format plugin, so you can bring in files from Mappy and Tiled.

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

### Who is online

Users browsing this forum: Bing [Bot] and 12 guests