mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-04-30 13:31:39 -04:00
Fix the behaviors.lua random function
Sometimes the arguments to the random function in behaviors.lua are swapped because of negative coordinates, this commit introduces a wrapper for the random function which makes sure that math.random gets its arguments in the correct order.
This commit is contained in:
parent
8954aa3493
commit
e885754e98
1 changed files with 12 additions and 1 deletions
|
@ -12,7 +12,18 @@ local floor = math.floor
|
|||
local pi = math.pi
|
||||
local sin = math.sin
|
||||
local rad = math.rad
|
||||
local random = math.random
|
||||
|
||||
-- fix for negative coordinates
|
||||
local function random(a,b)
|
||||
if b == nil then
|
||||
return math.random(a)
|
||||
elseif a < b then
|
||||
return math.random(a,b)
|
||||
else
|
||||
return math.random(b,a)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function diff(a, b) -- Get difference between 2 angles
|
||||
return atan2(sin(b - a), cos(b - a))
|
||||
|
|
Loading…
Add table
Reference in a new issue