Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.
/ LuaPill Public archive

A Lua library for creating and loading isometric maps

License

Notifications You must be signed in to change notification settings

Kyrremann/LuaPill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LuaPill

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.

Example

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

The config table

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
   }

API

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.

Input/controls

  • 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

TODO

  • 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

Installation

Just copy the luapill.lua file wherever you want it. Then require it where you need it:

local luapill = require "luapill"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

LuaPill is licensed under zlib/libpng License (Zlib), see the LICENSE.md.

About

A Lua library for creating and loading isometric maps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages