[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 » Sat Jan 30, 2016 6:49 pm

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: 728
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Library] pixelmap

Post by bobbyjones » Sat Jan 30, 2016 7:39 pm

You could use Tiled and STI.
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.

User avatar
aloisdeniel
Prole
Posts: 17
Joined: Sat Jan 30, 2016 5:57 pm
Contact:

Re: [Library] pixelmap

Post by aloisdeniel » Sat Jan 30, 2016 9:11 pm

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 » Wed Feb 03, 2016 11:11 pm

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: 728
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Library] pixelmap & pixelatlas

Post by bobbyjones » Thu Feb 04, 2016 4:35 am

I like your logos. They are pretty.
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests