diff --git a/assets/entities/nancy/moth_mask/slide1.png b/assets/entities/nancy/moth_mask/slide1.png new file mode 100644 index 0000000..8398434 Binary files /dev/null and b/assets/entities/nancy/moth_mask/slide1.png differ diff --git a/assets/entities/nancy/moth_mask/slide2.png b/assets/entities/nancy/moth_mask/slide2.png new file mode 100644 index 0000000..8398434 Binary files /dev/null and b/assets/entities/nancy/moth_mask/slide2.png differ diff --git a/assets/entities/nancy/moth_mask/slide3.png b/assets/entities/nancy/moth_mask/slide3.png new file mode 100644 index 0000000..8398434 Binary files /dev/null and b/assets/entities/nancy/moth_mask/slide3.png differ diff --git a/assets/entities/nancy/slide1.png b/assets/entities/nancy/slide1.png new file mode 100644 index 0000000..34758ba Binary files /dev/null and b/assets/entities/nancy/slide1.png differ diff --git a/assets/entities/nancy/slide2.png b/assets/entities/nancy/slide2.png new file mode 100644 index 0000000..09333fe Binary files /dev/null and b/assets/entities/nancy/slide2.png differ diff --git a/assets/entities/nancy/slide3.png b/assets/entities/nancy/slide3.png new file mode 100644 index 0000000..7c0a659 Binary files /dev/null and b/assets/entities/nancy/slide3.png differ diff --git a/code/entities/fairy.lua b/code/entities/fairy.lua index 27403aa..07fe733 100644 --- a/code/entities/fairy.lua +++ b/code/entities/fairy.lua @@ -10,7 +10,7 @@ function Fairy:new(x,y) o.range = 20 o.vision_range = 120 o.target = {x = x, y = y} - o.hover_distance = 60 + o.hover_distance = 40 -- animations o.body = Animation:new(animation.fairy.flying) @@ -41,8 +41,8 @@ function Fairy:doLogic() local below = 1 while not isThereObjectAt( - self.target.x, - self.target.y + below * game.scale, + self.pos.x, + self.pos.y + below * game.scale, LoadedObjects.Collisions ) do below = below + 1 @@ -50,8 +50,8 @@ function Fairy:doLogic() end local top = 1 while not isThereObjectAt( - self.target.x, - self.target.y - top * game.scale, + self.pos.x, + self.pos.y - top * game.scale, LoadedObjects.Collisions ) do top = top + 1 diff --git a/code/entities/player.lua b/code/entities/player.lua index d9a6698..87acd49 100644 --- a/code/entities/player.lua +++ b/code/entities/player.lua @@ -71,7 +71,7 @@ function Player:new(x,y) o.mask = Animation:new(animation.moth_mask.idle) o:centerOffset(o.body) - o:createBox(o.body,0,3,-1,-3) + o:createBox(o.body,0,4,-1,-5) -- lights 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 and not self.is_dashing and self.dash_count > 0 then + self:unhook() + self.nodrift_frames = 0 -- state player self.is_dashing = true + self.is_sliding = false self.dash_count = self.dash_count - 1 -- get dash direction @@ -312,9 +315,11 @@ function Player:handleAnimation() elseif self.move_x ~= 0 then self.sprite_flip.x = math.sign(self.move_x) end - -- 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.mask = self.mask:change(self.mask_type.fall) elseif self.vel.y < 0 then diff --git a/code/entity.lua b/code/entity.lua index 9c09fa1..56f6852 100644 --- a/code/entity.lua +++ b/code/entity.lua @@ -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 diff --git a/data/animations.lua b/data/animations.lua index 7f821e3..14830c4 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -140,6 +140,15 @@ animation.moth_mask.fall = { 1/8 } } + +animation.moth_mask.slide = { + path = "assets/entities/nancy/moth_mask/slide", + frames = { + 1/8, + 1/8, + 1/8 + } +} animation.moth_mask.jump = { path = "assets/entities/nancy/moth_mask/jump", frames = { @@ -179,6 +188,14 @@ animation.nancy.fall = { 1/8 } } +animation.nancy.slide = { + path = "assets/entities/nancy/slide", + frames = { + 1/8, + 1/8, + 1/8 + } +} animation.nancy.jump = { path = "assets/entities/nancy/jump", frames = {