bugfix and slide animation
- bugfix for hook swing not taking in consideration the length of rope - bugfix for player hitbox size - bugfix for fairy flight control system FCS - added slide animation for wall slide and wall jump
This commit is contained in:
@@ -38,21 +38,29 @@ end
|
||||
function Entity:checkNearest(type,maxdistance)
|
||||
local return_entity = nil
|
||||
local shortest = -1
|
||||
local flag_variable_distance = false
|
||||
|
||||
if maxdistance == "hook_specific" then
|
||||
flag_variable_distance = true
|
||||
end
|
||||
|
||||
for _, entity in pairs(LoadedObjects.Entities) do
|
||||
if not type or entity.type == type then
|
||||
local distance_x = entity.pos.x - self.pos.x
|
||||
local distance_y = entity.pos.y - self.pos.y
|
||||
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
|
||||
|
||||
if maxdistance == "hook_specific" then maxdistance = entity.hook_distance end
|
||||
if flag_variable_distance then
|
||||
maxdistance = entity.hook_distance
|
||||
end
|
||||
|
||||
if not maxdistance or distance < maxdistance then
|
||||
if shortest == -1 or distance < shortest then
|
||||
shortest = distance
|
||||
return_entity = entity
|
||||
end
|
||||
print(shortest,maxdistance,distance)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
return return_entity
|
||||
@@ -67,20 +75,19 @@ function Entity:move()
|
||||
end
|
||||
|
||||
function Entity:moveWithCollision()
|
||||
local r = false
|
||||
-- horizontal collision
|
||||
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
else
|
||||
self.vel.x = 0
|
||||
r = true
|
||||
end
|
||||
|
||||
-- vertical collision
|
||||
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then
|
||||
self.pos.y = self.pos.y + self.vel.y
|
||||
else
|
||||
self.vel.y = 0
|
||||
r = true
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
function Entity:adjustLight(x,y)
|
||||
@@ -136,6 +143,7 @@ function Entity:checkVisionLine(entity,range)
|
||||
end
|
||||
|
||||
function Entity:draw(animation)
|
||||
if animation == nil then return end
|
||||
local c1, c2, c3, a = love.graphics.getColor()
|
||||
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
|
||||
animation:draw(
|
||||
@@ -149,6 +157,7 @@ function Entity:draw(animation)
|
||||
end
|
||||
|
||||
function Entity:centerOffset(animation,x,y)
|
||||
if animation == nil then return end
|
||||
local x = x or 0
|
||||
local y = y or 0
|
||||
self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x
|
||||
@@ -156,6 +165,7 @@ function Entity:centerOffset(animation,x,y)
|
||||
end
|
||||
|
||||
function Entity:createBox(animation,top,left,bottom,right)
|
||||
if animation == nil then return end
|
||||
local left = left or 0
|
||||
local right = right or 0
|
||||
local top = top or 0
|
||||
|
||||
Reference in New Issue
Block a user