|
@@ -8,6 +8,7 @@ function Person:activate()
|
|
self.h = 35
|
|
self.h = 35
|
|
self.w = self.h * widthRatio
|
|
self.w = self.h * widthRatio
|
|
self.scale = self.h / self.image:getHeight()
|
|
self.scale = self.h / self.image:getHeight()
|
|
|
|
+ self.alpha = 1
|
|
|
|
|
|
self.body = love.physics.newBody(ctx.world, self.x - self.w / 2, self.y - self.h / 2, 'dynamic')
|
|
self.body = love.physics.newBody(ctx.world, self.x - self.w / 2, self.y - self.h / 2, 'dynamic')
|
|
self.shape = love.physics.newRectangleShape(self.w, self.h)
|
|
self.shape = love.physics.newRectangleShape(self.w, self.h)
|
|
@@ -20,7 +21,7 @@ function Person:activate()
|
|
self.fixture:setCategory(ctx.categories.person)
|
|
self.fixture:setCategory(ctx.categories.person)
|
|
self.fixture:setMask(ctx.categories.person, ctx.categories.building, ctx.categories.debris)
|
|
self.fixture:setMask(ctx.categories.person, ctx.categories.building, ctx.categories.debris)
|
|
|
|
|
|
- self.phlerp = PhysicsInterpolator(self.body)
|
|
|
|
|
|
+ self.phlerp = PhysicsInterpolator(self, 'alpha')
|
|
|
|
|
|
ctx.event:emit('view.register', {object = self})
|
|
ctx.event:emit('view.register', {object = self})
|
|
|
|
|
|
@@ -43,10 +44,10 @@ end
|
|
function Person:draw()
|
|
function Person:draw()
|
|
local g = love.graphics
|
|
local g = love.graphics
|
|
|
|
|
|
- self.phlerp:lerp()
|
|
|
|
-
|
|
|
|
|
|
+ local lerpd = self.phlerp:lerp()
|
|
local x, y, angle = self.body:getX(), self.body:getY(), self.body:getAngle()
|
|
local x, y, angle = self.body:getX(), self.body:getY(), self.body:getAngle()
|
|
- g.setColor(255, 255, 255)
|
|
|
|
|
|
+
|
|
|
|
+ g.setColor(255, 255, 255, 255 * math.clamp(lerpd.alpha, 0, 1))
|
|
g.draw(self.image, x, y, angle, self.scale * self.direction, self.scale, self.image:getWidth() / 2, self.image:getHeight() / 2)
|
|
g.draw(self.image, x, y, angle, self.scale * self.direction, self.scale, self.image:getWidth() / 2, self.image:getHeight() / 2)
|
|
|
|
|
|
self.phlerp:delerp()
|
|
self.phlerp:delerp()
|
|
@@ -89,7 +90,10 @@ end
|
|
|
|
|
|
function Person.dead:update()
|
|
function Person.dead:update()
|
|
local x, y = self.body:getLinearVelocity()
|
|
local x, y = self.body:getLinearVelocity()
|
|
- if (math.abs(x) < 1 and math.abs(y) < 1) or (math.abs(x) > 5000 and math.abs(y) > 5000) then
|
|
|
|
- ctx.enemies:remove(self)
|
|
|
|
|
|
+ if (math.abs(x) < 1 and math.abs(y) < 1) or (math.abs(x) > 2000 and math.abs(y) > 2000) then
|
|
|
|
+ self.alpha = self.alpha - ls.tickrate
|
|
|
|
+ if self.alpha <= 0 then
|
|
|
|
+ ctx.enemies:remove(self)
|
|
|
|
+ end
|
|
end
|
|
end
|
|
end
|
|
end
|