adjusted hook to be toggle; renamed HasPressed to CheckPressed (keybind)
This commit is contained in:
@@ -140,17 +140,19 @@ function Player:Smart()
|
||||
self.isDashing = false
|
||||
end
|
||||
|
||||
if Keybind:CheckDown(Keybind.move.hook) then
|
||||
local anchor = self:CheckNearest("decoration",self.hookDistance)
|
||||
if anchor then
|
||||
self.isHooked = true
|
||||
self.hookAnchor = {
|
||||
x = anchor.pos.x,
|
||||
y = anchor.pos.y
|
||||
}
|
||||
if Keybind:CheckPressed(Keybind.move.hook) then
|
||||
if self.isHooked then
|
||||
self.isHooked = false
|
||||
else
|
||||
local anchor = self:CheckNearest("decoration",self.hookDistance)
|
||||
if anchor then
|
||||
self.isHooked = true
|
||||
self.hookAnchor = {
|
||||
x = anchor.pos.x,
|
||||
y = anchor.pos.y
|
||||
}
|
||||
end
|
||||
end
|
||||
else
|
||||
self.isHooked = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -194,9 +196,19 @@ function Player:DoPhysics()
|
||||
if self.isHooked then
|
||||
local hook = Vector(self.pos.x, self.pos.y, self.hookAnchor.x, self.hookAnchor.y)
|
||||
if GetVectorValue(hook) > self.hookedDistance then
|
||||
local hook_angle = GetAngleFromVector(hook[1],hook[2])
|
||||
local pos_x = self.hookAnchor.x + self.hookedDistance * math.cos(-math.rad(180)+hook_angle)
|
||||
local pos_y = self.hookAnchor.y + self.hookedDistance * math.sin(-math.rad(180)+hook_angle)
|
||||
local particle_data = {
|
||||
animation = self.body,
|
||||
sprite_tint = HEX2RGB("#fed100"),
|
||||
sprite_alpha = 0.5,
|
||||
sprite_flip = {
|
||||
x = self.sprite_flip.x,
|
||||
y = self.sprite_flip.y
|
||||
}
|
||||
}
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
local hook_angle = GetAngleFromVector(hook[1],hook[2])-math.rad(180)
|
||||
local pos_x = self.hookAnchor.x + self.hookedDistance * math.cos(hook_angle)
|
||||
local pos_y = self.hookAnchor.y + self.hookedDistance * math.sin(hook_angle)
|
||||
self.vel.x = self.vel.x + pos_x - self.pos.x
|
||||
self.vel.y = self.vel.y + pos_y - self.pos.y
|
||||
self.pos.x = pos_x
|
||||
@@ -206,7 +218,7 @@ function Player:DoPhysics()
|
||||
|
||||
|
||||
if self.canFall then
|
||||
-- not in dash or hook; fall normally
|
||||
-- not in dash
|
||||
self.dashTimer = 0
|
||||
self.vel.y = self.vel.y + gravity
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user