|
@@ -25,6 +25,8 @@ Player.collision = {
|
|
|
-- Core
|
|
|
----------------
|
|
|
function Player:init()
|
|
|
+ self.meta = {__index = self}
|
|
|
+
|
|
|
self.id = nil
|
|
|
self.username = ''
|
|
|
self.class = nil
|
|
@@ -45,6 +47,7 @@ function Player:init()
|
|
|
|
|
|
self.lifesteal = 0
|
|
|
self.haste = 0
|
|
|
+ self.cloak = 0
|
|
|
|
|
|
self.depth = 0
|
|
|
self.recoil = 0
|
|
@@ -68,13 +71,17 @@ function Player:activate()
|
|
|
self.depth = -self.id
|
|
|
end
|
|
|
|
|
|
-Player.update = f.empty
|
|
|
+function Player:update()
|
|
|
+ if self.recoil > 0 then self.recoil = math.lerp(self.recoil, 0, math.min(5 * tickRate, 1)) end
|
|
|
+ self.cloak = timer.rot(self.cloak)
|
|
|
+end
|
|
|
|
|
|
function Player:draw()
|
|
|
local g, c = love.graphics, self.class
|
|
|
- g.setColor(0, 0, 0, self.alpha * 50)
|
|
|
+ local alpha = self.alpha * (1 - (self.cloak / (self.team == ctx.players:get(ctx.id).team and 2 or 1)))
|
|
|
+ g.setColor(0, 0, 0, alpha * 50)
|
|
|
g.draw(c.sprite, self.x + 4, self.y + 4, self.angle, 1, 1, c.anchorx, c.anchory)
|
|
|
- g.setColor(self.team == purple and {190, 160, 200, self.alpha * 255} or {240, 160, 140, self.alpha * 255})
|
|
|
+ g.setColor(self.team == purple and {190, 160, 200, alpha * 255} or {240, 160, 140, alpha * 255})
|
|
|
g.draw(c.sprite, self.x, self.y, self.angle, 1, 1, c.anchorx, c.anchory)
|
|
|
f.exe(self.slots[self.weapon].draw, self.slots[self.weapon], self)
|
|
|
f.exe(self.slots[self.skill].draw, self.slots[self.skill], self)
|
|
@@ -85,6 +92,10 @@ end
|
|
|
-- Behavior
|
|
|
----------------
|
|
|
function Player:move(input)
|
|
|
+ if input.reposition then
|
|
|
+ self.x, self.y = input.reposition.x, input.reposition.y
|
|
|
+ end
|
|
|
+
|
|
|
local w, a, s, d = input.w, input.a, input.s, input.d
|
|
|
if not (w or a or s or d) then return end
|
|
|
|
|
@@ -100,7 +111,7 @@ function Player:move(input)
|
|
|
local dir = (dx + dy) / 2
|
|
|
local len = (self.class.speed + self.haste) * tickRate
|
|
|
self.x, self.y = self.x + math.dx(len, dir), self.y + math.dy(len, dir)
|
|
|
-
|
|
|
+
|
|
|
self.x = math.clamp(self.x, 0, ctx.map.width)
|
|
|
self.y = math.clamp(self.y, 0, ctx.map.height)
|
|
|
|
|
@@ -135,16 +146,16 @@ function Player:slot(input)
|
|
|
end
|
|
|
|
|
|
if input.l and weapon:canFire(self) then
|
|
|
+ weapon:fire(self, input.x, input.y)
|
|
|
ctx.net:emit(evtFire, {id = self.id, slot = self.weapon})
|
|
|
end
|
|
|
|
|
|
if input.r and skill:canFire(self) then
|
|
|
+ skill:fire(self, input.x, input.y)
|
|
|
ctx.net:emit(evtFire, {id = self.id, slot = self.skill})
|
|
|
end
|
|
|
|
|
|
if input.reload then weapon:reload(self) end
|
|
|
-
|
|
|
- if self.recoil > 0 then self.recoil = math.lerp(self.recoil, 0, math.min(5 * tickRate, 1)) end
|
|
|
end
|
|
|
|
|
|
Player.hurt = f.empty
|