LuaPill (short for "Practical Isometric Layering Library for Lua") is an engine for generating isometric maps for Löve2D and Lua. See Example for usage, or try the demo. Just git clone
the repository and run love demo
.
function love.load()
map = require "luapill"
local config = {
tilewidth = 128,
tileheight = 64,
folder = "images"
}
map:setup(config)
end
function love.update(dt)
end
function love.draw()
map:draw()
end
config = {
tilewidth = number, -- required
tilewidth = number, -- required
folder = "path", -- required
sortFolder = boolean, -- optional, default false
defaultTile = number, -- optional, default 1
tileIndex = number -- optional, default 1
}
function luapill:saveMap()
Called to save the current map and tiles. Output in JSON-format.
function luapill:loadMap(path)
Load a map from a given path.
function luapill:getTile(index)
Get the tile based on the index it has in the image folder.
function luapill:getTileCount()
Number of tiles in the image folder.
function luapill:getScale()
Current scale or zoom-level.
function luapill:getTileIndex()
Returns the current selected tile index.
function luapill:mousepressed(x, y, button)
Sends mouse pressed to the library.
function luapill:keyreleased(key)
Sends key realeasing to the library.
function luapill:keypressed(key)
Sends key pressing to the library.
function luapill:getMouseAsMap()
Get mouse coordinates as a map, call goes through screenToMap()
.
function luapill:screenToMap(screen)
Converts screen coordinates (pixels) to map coordinates (double array).
function luapill:mapToScreen(map)
Converts map coordinates (double array) to screen coordinates (pixels).
function luapill:draw()
Draws the map to the screen, usually called in love.draw().
function luapill:zoomMap(scale)
Zooms tha map either postively or negatively. Maximum is 2, and minimum is 0.2.
function luapill:shiftTile(by)
Shift to the next tile, based on the value sent in.
function luapill:getCamera()
Get the coordinates for the camera.
function luapill:moveCamera(x, y)
Moves the camera to the x- and y-axis.
function luapill:placeTile()
Place a new tile at the given location, overriding the previous tile.
- Move tile with mouse
- Left click to place tile
- Shift + scroll to zoom in or out
- You can also use + and -
- Scroll to cycle through different tiles
- You can also use + and -
- Escape to quit
- Use WASD to move around the map
- Load map frome file
- F6 to load a level
- Save map to file
- F5 to save level
- Different elevation
- Right click to rotate (only works if the tiles are sorted)
- Allow for custom keybindings
- Keybindings have been removed from the library, should be handled by the game
Just copy the luapill.lua file wherever you want it. Then require it where you need it:
local luapill = require "luapill"
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
LuaPill is licensed under zlib/libpng License (Zlib), see the LICENSE.md.