change rope swinging physics a bit

This commit is contained in:
binarycat 2022-02-26 17:44:29 -05:00 committed by lustlion
parent 4ae314f422
commit a3cfe1fed3
1 changed files with 7 additions and 7 deletions

View File

@ -91,7 +91,7 @@ function Player:Smart()
if self.noDriftFrames > 0 then
self.move_x = 0
elseif Keybind:CheckDown(Keybind.move.left) then
self.move_x = -1
self.move_x = -self.moveSpeed
self.vel.x = math.min(self.vel.x, -self.moveSpeed)
elseif Keybind:CheckDown(Keybind.move.right) then
self.move_x = 1
@ -208,14 +208,15 @@ function Player:DoPhysics()
-- hook state
if self.isHooked then
local hook = Vector(self.pos.x, self.pos.y, self.hookAnchor.x, self.hookAnchor.y)
if GetVectorValue(hook) > self.hookDistance then
local dist = math.min(GetVectorValue(hook), self.hookDistance)
local hook_angle = GetAngleFromVector(hook[1],hook[2])-math.rad(180)
if Keybind:CheckDown(Keybind.move.right) then
hook_angle = hook_angle - math.rad(0.05)
hook_angle = hook_angle - math.rad(0.1)
self.move_x = 0
end
if Keybind:CheckDown(Keybind.move.left) then
hook_angle = hook_angle + math.rad(0.05)
hook_angle = hook_angle + math.rad(0.1)
self.move_x = 0
end
@ -230,14 +231,13 @@ function Player:DoPhysics()
}
Particle:New(self.pos.x,self.pos.y,particle_data)
local pos_x = self.hookAnchor.x + self.hookDistance * math.cos(hook_angle)
local pos_y = self.hookAnchor.y + self.hookDistance * math.sin(hook_angle)
local pos_x = self.hookAnchor.x + dist * math.cos(hook_angle)
local pos_y = self.hookAnchor.y + dist * 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
self.pos.y = pos_y
end
end
if self.canFall then