]> git.lizzy.rs Git - lua-star.git/commitdiff
Add example animation.
authorWesley <wesley.werner@gmail.com>
Sat, 27 Oct 2018 08:29:13 +0000 (10:29 +0200)
committerWesley <wesley.werner@gmail.com>
Sat, 27 Oct 2018 08:29:13 +0000 (10:29 +0200)
README.md
example/example.gif [new file with mode: 0644]
example/main.lua

index 5cb49b5b67c69074871c82fcc62357aa47caeaeb..3bee2eb1a38729097a52cfda29e70baa7ea4059b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![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
 
diff --git a/example/example.gif b/example/example.gif
new file mode 100644 (file)
index 0000000..f84d9fb
Binary files /dev/null and b/example/example.gif differ
index dfea8495d2b40323dabcf32f68753c988ddfbef1..0610703c59db2160dff2f90e7307818f11450ab8 100644 (file)
@@ -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)