From fa34bc46a829a757f4cac1855e228fa5b8915ec8 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sat, 28 Aug 2010 23:32:43 +0000 Subject: [PATCH] fix git-svn-id: http://svn.net-core.org/repos/t-engine4@1098 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/example/class/Player.lua | 8 +++++++- game/modules/tome/class/Player.lua | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/game/modules/example/class/Player.lua b/game/modules/example/class/Player.lua index 4182b135a9..7ec5bee734 100644 --- a/game/modules/example/class/Player.lua +++ b/game/modules/example/class/Player.lua @@ -80,12 +80,18 @@ function _M:act() end end +-- Precompute FOV form, for speed +local fovdist = {} +for i = 0, 30 * 30 do + fovdist[i] = math.max((20 - math.sqrt(i)) / 14, 0.6) +end + function _M:playerFOV() -- Clean FOV before computing it game.level.map:cleanFOV() -- Compute both the normal and the lite FOV, using cache self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) - game.level.map:apply(x, y, math.max((20 - math.sqrt(sqdist)) / 14, 0.6)) + game.level.map:apply(x, y, fovdist[sqdist]) end, true, false, true) self:computeFOV(self.lite, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true, true) end diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 90daf0455d..612b2cfbea 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -182,7 +182,7 @@ function _M:act() end end --- Precompute FOV form +-- Precompute FOV form, for speed local fovdist = {} for i = 0, 30 * 30 do fovdist[i] = math.max((20 - math.sqrt(i)) / 14, 0.6) -- GitLab