You need to familiarize yourself with using deltatime as a multiplier.ishkabible wrote:really? i slowed them down? mabey check to see if it's waiting for the v sync in the config file? any one else having this issue?TechnoCat wrote:I can't play because zombies move at the speed of light.
/scripts/Zombie.lua:32
Code: Select all
function Zombie:update()
local px = ThePlayer.x
local py = ThePlayer.y
local zx = self.x
local zy = self.y
self.theta = math.atan2(py-zy,px-zx) + math.pi/2
local ix = math.sin(self.theta)*self.speed
local iy = -math.cos(self.theta)*self.speed
self.x = zx + ix
self.y = zy + iy
end
What you should take from this is that self.x = zx + ix is a computation based speed. If my computer if faster than yours, then my computer is going to be doing self.x = zx + ix a lot faster than yours, making zombies very fast. However, if you pass the dt from love.update(dt) into Zombie:update() as Zombie:update(dt) and then change self.x = zx + ix to self.x = zx + ix*dt, it will only do a full ix increase every second on every computer.
Code: Select all
function Zombie:update(dt)
local px = ThePlayer.x
local py = ThePlayer.y
local zx = self.x
local zy = self.y
self.theta = math.atan2(py-zy,px-zx) + math.pi/2
local ix = math.sin(self.theta)*self.speed*dt
local iy = -math.cos(self.theta)*self.speed*dt
self.x = zx + ix
self.y = zy + iy
end