diff options
author | Wesley <wesley.werner@gmail.com> | 2018-10-27 10:29:13 +0200 |
---|---|---|
committer | Wesley <wesley.werner@gmail.com> | 2018-10-27 10:29:13 +0200 |
commit | 281bc15b671406f785838b2b105d57079f31df38 (patch) | |
tree | b5840b021f14e44c7ac79350ff7e9c799dbb6610 | |
parent | 694be3aa7c449b04b13f461a8ac87905702f4519 (diff) | |
download | lua-star-281bc15b671406f785838b2b105d57079f31df38.tar.xz |
Add example animation.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | example/example.gif | bin | 0 -> 89675 bytes | |||
-rw-r--r-- | example/main.lua | 17 |
3 files changed, 15 insertions, 4 deletions
@@ -2,7 +2,7 @@ [](https://travis-ci.org/wesleywerner/lua-star) Lua-star is a pure Lua A* path-finding library. - + # Quick Start diff --git a/example/example.gif b/example/example.gif Binary files differnew file mode 100644 index 0000000..f84d9fb --- /dev/null +++ b/example/example.gif diff --git a/example/main.lua b/example/main.lua index dfea849..0610703 100644 --- a/example/main.lua +++ b/example/main.lua @@ -29,6 +29,9 @@ local hoveredTile local largeFont = love.graphics.newFont (30) local smallFont = love.graphics.newFont (10) +-- save a screenshot +local saveScreenshot = false + function randomizeMap () -- build an open map @@ -41,10 +44,10 @@ function randomizeMap () -- 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 @@ -58,6 +61,7 @@ function randomizeMap () end requestPath() + --saveScreenshot = true end @@ -107,6 +111,13 @@ function love.draw () 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) |