[Library] pixelmap & pixelatlas

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
aloisdeniel
Prole
Posts: 17
Joined: Sat Jan 30, 2016 5:57 pm
Contact:

[Library] pixelmap & pixelatlas

Post by aloisdeniel »

Hi,

I'm new to LÖVE and Lua world, but I made a little library that could help with tilemap loading. For prototyping, I've already been frustrated of editing my map directly from from array of ids or chars : I find it difficult to imagine the final look of the map.

Image

Version 1.1.0

That's why I've developped this little library that "translates" pixel color value to tiles.

So basically you register your colors, and then the library loads your tiles coordinates from pixel information. It is also possible to precise groups for tiles, and all adjacent tiles with same group will generate rectangles (for collision purposes for example).

Code: Select all

local pixelmap = require('pixelmap')

pixelmap.register(0) -- Default tile
pixelmap.register(1, "#86a36bff", { "Ground" })
pixelmap.register(2, "#a47550ff", { "Ground" })
pixelmap.register(3, "#6e5a4aff")

local map = pixelmap.load('map.png')

--[[
{
    tiles= {
        {0,0,0,0,0,0}
        {0,0,1,1,0,3}
        {0,0,2,2,0,3}
    },
    groups = {
        "Ground" = { { x=3,y=2,w=2,h=2} }
    }
}]]
For performance reason, after the first load, the table result will be saved into application local storage, and at next load requests, this file will be loaded instead of the image.

Obviously a "real" map editor is far better, but a lot of work too : this library is intended to speed up my prototyping phases. I've almost no experience with lua and LÔVE so don't hesitate to give me some suggestions to improve the code quality !

The library is available here : https://github.com/aloisdeniel/love-pixelmap

Image

Version 1.0.0

I've also developed a texture atlas loader from pixel information. It basically cut your image into quads from a predefined pixel color separator.

Image

Code: Select all

local pixelatlas = require('pixelatlas')

pixelatlas.register("#86a36bff")

local image, quads = pixelatlas.load('atlas.png')

--[[
{
    <quad 1x1x16x16>,
    <quad 17x1x16x32>,
    ...
}]]
The library is available here : https://github.com/aloisdeniel/love-pixelatlas
Last edited by aloisdeniel on Wed Feb 03, 2016 11:13 pm, edited 4 times in total.
My LÖVE libraries : pixelatlas, pixelmap
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Library] pixelmap

Post by bobbyjones »

You could use Tiled and STI.
User avatar
aloisdeniel
Prole
Posts: 17
Joined: Sat Jan 30, 2016 5:57 pm
Contact:

Re: [Library] pixelmap

Post by aloisdeniel »

Ow yes, thanks for pointing me out this great tool ! For more ambitious projets it will be perfect. :) But I kinda like my library, for simplier solutions.
My LÖVE libraries : pixelatlas, pixelmap
User avatar
aloisdeniel
Prole
Posts: 17
Joined: Sat Jan 30, 2016 5:57 pm
Contact:

Re: [Library] pixelmap & pixelatlas

Post by aloisdeniel »

I updated the library and changed the output format (arrays instead of tables). I've also added a small library that extracts quads from an image that contains separator pixels with a registered color.
My LÖVE libraries : pixelatlas, pixelmap
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Library] pixelmap & pixelatlas

Post by bobbyjones »

I like your logos. They are pretty.
Post Reply

Who is online

Users browsing this forum: No registered users and 216 guests