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:
parent
9ada88f4f5
commit
6e76607030
BIN
assets/entities/nancy/moth_mask/slide1.png
Normal file
BIN
assets/entities/nancy/moth_mask/slide1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
BIN
assets/entities/nancy/moth_mask/slide2.png
Normal file
BIN
assets/entities/nancy/moth_mask/slide2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
BIN
assets/entities/nancy/moth_mask/slide3.png
Normal file
BIN
assets/entities/nancy/moth_mask/slide3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
BIN
assets/entities/nancy/slide1.png
Normal file
BIN
assets/entities/nancy/slide1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/entities/nancy/slide2.png
Normal file
BIN
assets/entities/nancy/slide2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/entities/nancy/slide3.png
Normal file
BIN
assets/entities/nancy/slide3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -10,7 +10,7 @@ function Fairy:new(x,y)
|
|||||||
o.range = 20
|
o.range = 20
|
||||||
o.vision_range = 120
|
o.vision_range = 120
|
||||||
o.target = {x = x, y = y}
|
o.target = {x = x, y = y}
|
||||||
o.hover_distance = 60
|
o.hover_distance = 40
|
||||||
|
|
||||||
-- animations
|
-- animations
|
||||||
o.body = Animation:new(animation.fairy.flying)
|
o.body = Animation:new(animation.fairy.flying)
|
||||||
@ -41,8 +41,8 @@ function Fairy:doLogic()
|
|||||||
|
|
||||||
local below = 1
|
local below = 1
|
||||||
while not isThereObjectAt(
|
while not isThereObjectAt(
|
||||||
self.target.x,
|
self.pos.x,
|
||||||
self.target.y + below * game.scale,
|
self.pos.y + below * game.scale,
|
||||||
LoadedObjects.Collisions
|
LoadedObjects.Collisions
|
||||||
) do
|
) do
|
||||||
below = below + 1
|
below = below + 1
|
||||||
@ -50,8 +50,8 @@ function Fairy:doLogic()
|
|||||||
end
|
end
|
||||||
local top = 1
|
local top = 1
|
||||||
while not isThereObjectAt(
|
while not isThereObjectAt(
|
||||||
self.target.x,
|
self.pos.x,
|
||||||
self.target.y - top * game.scale,
|
self.pos.y - top * game.scale,
|
||||||
LoadedObjects.Collisions
|
LoadedObjects.Collisions
|
||||||
) do
|
) do
|
||||||
top = top + 1
|
top = top + 1
|
||||||
|
@ -71,7 +71,7 @@ function Player:new(x,y)
|
|||||||
o.mask = Animation:new(animation.moth_mask.idle)
|
o.mask = Animation:new(animation.moth_mask.idle)
|
||||||
|
|
||||||
o:centerOffset(o.body)
|
o:centerOffset(o.body)
|
||||||
o:createBox(o.body,0,3,-1,-3)
|
o:createBox(o.body,0,4,-1,-5)
|
||||||
|
|
||||||
-- lights
|
-- lights
|
||||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius)
|
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius)
|
||||||
@ -131,10 +131,13 @@ function Player:doLogic()
|
|||||||
if self.dash_cooldown_timer == 0
|
if self.dash_cooldown_timer == 0
|
||||||
and not self.is_dashing
|
and not self.is_dashing
|
||||||
and self.dash_count > 0 then
|
and self.dash_count > 0 then
|
||||||
|
|
||||||
self:unhook()
|
self:unhook()
|
||||||
|
self.nodrift_frames = 0
|
||||||
|
|
||||||
-- state player
|
-- state player
|
||||||
self.is_dashing = true
|
self.is_dashing = true
|
||||||
|
self.is_sliding = false
|
||||||
self.dash_count = self.dash_count - 1
|
self.dash_count = self.dash_count - 1
|
||||||
|
|
||||||
-- get dash direction
|
-- get dash direction
|
||||||
@ -312,9 +315,11 @@ function Player:handleAnimation()
|
|||||||
elseif self.move_x ~= 0 then
|
elseif self.move_x ~= 0 then
|
||||||
self.sprite_flip.x = math.sign(self.move_x)
|
self.sprite_flip.x = math.sign(self.move_x)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- animation priority
|
-- animation priority
|
||||||
if self.vel.y > 1.25 or self.is_sliding then
|
if self.is_sliding then
|
||||||
|
self.body = self.body:change(animation.nancy.slide)
|
||||||
|
self.mask = self.mask:change(self.mask_type.slide)
|
||||||
|
elseif self.vel.y > 1.25 then
|
||||||
self.body = self.body:change(animation.nancy.fall)
|
self.body = self.body:change(animation.nancy.fall)
|
||||||
self.mask = self.mask:change(self.mask_type.fall)
|
self.mask = self.mask:change(self.mask_type.fall)
|
||||||
elseif self.vel.y < 0 then
|
elseif self.vel.y < 0 then
|
||||||
|
@ -38,21 +38,29 @@ end
|
|||||||
function Entity:checkNearest(type,maxdistance)
|
function Entity:checkNearest(type,maxdistance)
|
||||||
local return_entity = nil
|
local return_entity = nil
|
||||||
local shortest = -1
|
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
|
for _, entity in pairs(LoadedObjects.Entities) do
|
||||||
if not type or entity.type == type then
|
if not type or entity.type == type then
|
||||||
local distance_x = entity.pos.x - self.pos.x
|
local distance_x = entity.pos.x - self.pos.x
|
||||||
local distance_y = entity.pos.y - self.pos.y
|
local distance_y = entity.pos.y - self.pos.y
|
||||||
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
|
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 not maxdistance or distance < maxdistance then
|
||||||
if shortest == -1 or distance < shortest then
|
if shortest == -1 or distance < shortest then
|
||||||
shortest = distance
|
shortest = distance
|
||||||
return_entity = entity
|
return_entity = entity
|
||||||
end
|
end
|
||||||
|
print(shortest,maxdistance,distance)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return return_entity
|
return return_entity
|
||||||
@ -67,20 +75,19 @@ function Entity:move()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Entity:moveWithCollision()
|
function Entity:moveWithCollision()
|
||||||
local r = false
|
-- horizontal collision
|
||||||
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
|
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
|
self.pos.x = self.pos.x + self.vel.x
|
||||||
else
|
else
|
||||||
self.vel.x = 0
|
self.vel.x = 0
|
||||||
r = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- vertical collision
|
||||||
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then
|
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
|
self.pos.y = self.pos.y + self.vel.y
|
||||||
else
|
else
|
||||||
self.vel.y = 0
|
self.vel.y = 0
|
||||||
r = true
|
|
||||||
end
|
end
|
||||||
return r
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:adjustLight(x,y)
|
function Entity:adjustLight(x,y)
|
||||||
@ -136,6 +143,7 @@ function Entity:checkVisionLine(entity,range)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Entity:draw(animation)
|
function Entity:draw(animation)
|
||||||
|
if animation == nil then return end
|
||||||
local c1, c2, c3, a = love.graphics.getColor()
|
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)
|
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
|
||||||
animation:draw(
|
animation:draw(
|
||||||
@ -149,6 +157,7 @@ function Entity:draw(animation)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Entity:centerOffset(animation,x,y)
|
function Entity:centerOffset(animation,x,y)
|
||||||
|
if animation == nil then return end
|
||||||
local x = x or 0
|
local x = x or 0
|
||||||
local y = y or 0
|
local y = y or 0
|
||||||
self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x
|
self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x
|
||||||
@ -156,6 +165,7 @@ function Entity:centerOffset(animation,x,y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Entity:createBox(animation,top,left,bottom,right)
|
function Entity:createBox(animation,top,left,bottom,right)
|
||||||
|
if animation == nil then return end
|
||||||
local left = left or 0
|
local left = left or 0
|
||||||
local right = right or 0
|
local right = right or 0
|
||||||
local top = top or 0
|
local top = top or 0
|
||||||
|
@ -140,6 +140,15 @@ animation.moth_mask.fall = {
|
|||||||
1/8
|
1/8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
animation.moth_mask.slide = {
|
||||||
|
path = "assets/entities/nancy/moth_mask/slide",
|
||||||
|
frames = {
|
||||||
|
1/8,
|
||||||
|
1/8,
|
||||||
|
1/8
|
||||||
|
}
|
||||||
|
}
|
||||||
animation.moth_mask.jump = {
|
animation.moth_mask.jump = {
|
||||||
path = "assets/entities/nancy/moth_mask/jump",
|
path = "assets/entities/nancy/moth_mask/jump",
|
||||||
frames = {
|
frames = {
|
||||||
@ -179,6 +188,14 @@ animation.nancy.fall = {
|
|||||||
1/8
|
1/8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
animation.nancy.slide = {
|
||||||
|
path = "assets/entities/nancy/slide",
|
||||||
|
frames = {
|
||||||
|
1/8,
|
||||||
|
1/8,
|
||||||
|
1/8
|
||||||
|
}
|
||||||
|
}
|
||||||
animation.nancy.jump = {
|
animation.nancy.jump = {
|
||||||
path = "assets/entities/nancy/jump",
|
path = "assets/entities/nancy/jump",
|
||||||
frames = {
|
frames = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user