[![Build Status](https://travis-ci.org/wesleywerner/lua-star.svg?branch=master)](https://travis-ci.org/wesleywerner/lua-star) Lua-star is a pure Lua A* path-finding library.
-![lua star example screenshot](example/lua-star-01.png)
+![lua star example screenshot](example/example.gif)
# Quick Start
local largeFont = love.graphics.newFont (30)
local smallFont = love.graphics.newFont (10)
+-- save a screenshot
+local saveScreenshot = false
+
function randomizeMap ()
-- build an open map
-- add random walls
math.randomseed (os.clock ())
- for i = 1, 25 do
+ for i = 1, 45 do
-- start point
- local x = math.random (2, mapsize-2)
- local y = math.random (2, mapsize-2)
+ local x = math.random (1, mapsize-2)
+ local y = math.random (1, mapsize-2)
-- vertical or horizontal
if math.random() > .5 then
for n = 1, 5 do
end
requestPath()
+ --saveScreenshot = true
end
love.graphics.print("*", (start.x-1) * tilesize, (start.y-1) * tilesize)
love.graphics.print("*", (goal.x-1) * tilesize, (goal.y-1) * tilesize)
+ if saveScreenshot then
+ saveScreenshot = false
+ local filename = string.format("screenshot-%d.png", os.time())
+ love.graphics.captureScreenshot(filename)
+ print (string.format("written %s", filename))
+ end
+
end
function love.mousemoved (x, y, dx, dy, istouch)