YAY
- Mask functionality - Rehandled Animations (now consistent)
This commit is contained in:
@@ -13,7 +13,10 @@ Arrow = Entity:New(x,y)
|
||||
o.sprite_offset = {x = 13, y = 1}
|
||||
o.stuck = false
|
||||
o.illuminated = true
|
||||
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.kupo.arrow)
|
||||
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
table.insert(LoadedEntities,o)
|
||||
@@ -25,7 +28,13 @@ function Arrow:Smart()
|
||||
end
|
||||
|
||||
function Arrow:HandleAnimation()
|
||||
self:LoadAnimation(animation.kupo.arrow)
|
||||
self.body:Draw(
|
||||
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
|
||||
self.sprite_rotation,
|
||||
self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.sprite_scale.y * self.sprite_flip.y
|
||||
)
|
||||
end
|
||||
|
||||
function Arrow:DoPhysics()
|
||||
|
||||
@@ -8,8 +8,12 @@ Kupo = Entity:New(x,y)
|
||||
o.range = 200
|
||||
o.target = {x = x, y = y}
|
||||
o.sprite_offset = {x = 8, y = 5}
|
||||
-- kupo bow
|
||||
o.bow = self:NewAnimation(animation.kupo.bow)
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.kupo.body)
|
||||
o.bow = Animation:New(animation.kupo.bow)
|
||||
|
||||
-- bow
|
||||
o.bow_flip = 1
|
||||
o.bow_rotation = 0
|
||||
o.bow_frame = 1
|
||||
@@ -19,7 +23,7 @@ Kupo = Entity:New(x,y)
|
||||
o.bow_frames = 6
|
||||
o.bow_extraframes = 18
|
||||
o.bow_aim_frames = 8
|
||||
o.hostile = false
|
||||
o.hostile = true
|
||||
|
||||
o.lightRange = o.range/10
|
||||
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
|
||||
@@ -131,29 +135,24 @@ end
|
||||
function Kupo:HandleAnimation()
|
||||
-- flip sprite to look in the direction is moving
|
||||
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
|
||||
self:LoadAnimation(animation.kupo.body)
|
||||
|
||||
self.body:Animate()
|
||||
self.body:Draw(
|
||||
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
|
||||
self.sprite_rotation,
|
||||
self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.sprite_scale.y * self.sprite_flip.y
|
||||
)
|
||||
|
||||
if self.draw_bow == true then
|
||||
DrawAnimationFrame(
|
||||
self.bow,
|
||||
self.bow:DrawFrame(
|
||||
math.min(self.bow_frame,self.bow_frames),
|
||||
self.pos.x + ( 8 * math.sin(self.bow_rotation)),
|
||||
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
|
||||
self.bow_rotation
|
||||
)
|
||||
end
|
||||
if debug_collision then
|
||||
love.graphics.setColor(1,0,0)
|
||||
love.graphics.line(
|
||||
self.pos.x - Camera.pos.x,
|
||||
self.pos.y - Camera.pos.y,
|
||||
self.target.x - Camera.pos.x,
|
||||
self.target.y - Camera.pos.y
|
||||
)
|
||||
love.graphics.circle( "line", self.pos.x - Camera.pos.x, self.pos.y - Camera.pos.y, self.range )
|
||||
love.graphics.setColor(1,1,1)
|
||||
love.graphics.print(self.bow_rotation, self.pos.x, self.pos.y+30)
|
||||
love.graphics.print(self.angle, self.pos.x, self.pos.y+50)
|
||||
end
|
||||
end
|
||||
|
||||
function Kupo:DoPhysics()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
|
||||
-- constants
|
||||
o.acc = 45
|
||||
o.acc = 45
|
||||
o.friction = 20
|
||||
o.gravity = 9.81
|
||||
o.climbHeight = 4
|
||||
@@ -31,11 +31,12 @@
|
||||
o.canJump = true
|
||||
o.canFall = true
|
||||
o.canFriction = true
|
||||
|
||||
-- sprite
|
||||
o.mask_type = animation.moth_mask
|
||||
-- sprite
|
||||
o.sprite_offset = {x = 8, y = 16}
|
||||
o.target_offset = {x = 0, y = 12}
|
||||
|
||||
o.target_offset = {x = 0, y = 12}
|
||||
o.body = Animation:New(animation.nancy.idle)
|
||||
o.mask = Animation:New(animation.moth_mask.idle)
|
||||
-- lights
|
||||
|
||||
|
||||
@@ -85,27 +86,53 @@ function Player:Smart()
|
||||
end
|
||||
|
||||
function Player:HandleAnimation()
|
||||
|
||||
-- flip sprite to look in the direction is moving
|
||||
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
|
||||
|
||||
-- animation manager
|
||||
if self.isOnLadder then
|
||||
self:LoadAnimation(animation.nancy.jump)
|
||||
self.body = self.body:ChangeTo(animation.nancy.jump)
|
||||
self.mask = self.mask:ChangeTo(self.mask_type.jump)
|
||||
elseif self.isOnGround == 0 and self.isJumping and self.vel.y > 1.25 then
|
||||
self:LoadAnimation(animation.nancy.fall)
|
||||
self.body = self.body:ChangeTo(animation.nancy.fall)
|
||||
self.mask = self.mask:ChangeTo(self.mask_type.fall)
|
||||
elseif self.isOnGround == 0 and self.vel.y < 0 then
|
||||
self:LoadAnimation(animation.nancy.jump)
|
||||
self.body = self.body:ChangeTo(animation.nancy.jump)
|
||||
self.mask = self.mask:ChangeTo(self.mask_type.jump)
|
||||
elseif self.vel.x ~= 0 then
|
||||
self:LoadAnimation(animation.nancy.run)
|
||||
self.body = self.body:ChangeTo(animation.nancy.run)
|
||||
self.mask = self.mask:ChangeTo(self.mask_type.run)
|
||||
else
|
||||
self:LoadAnimation(animation.nancy.idle)
|
||||
self.body = self.body:ChangeTo(animation.nancy.idle)
|
||||
self.mask = self.mask:ChangeTo(self.mask_type.idle)
|
||||
end
|
||||
|
||||
-- special case: idle animation gets slower by time
|
||||
if self.anim_path == animation.nancy.idle.path then
|
||||
if self.anim_speed < 0.5 then self.anim_speed = self.anim_speed + 0.001 end
|
||||
if self.body.anim_path == animation.nancy.idle.path then
|
||||
if self.body.anim_speed < 0.5 then self.body.anim_speed = self.body.anim_speed + 0.001 end
|
||||
end
|
||||
|
||||
self.body:Animate()
|
||||
self.body:Draw(
|
||||
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
|
||||
self.sprite_rotation,
|
||||
self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.sprite_scale.y * self.sprite_flip.y
|
||||
)
|
||||
self.mask:Draw(
|
||||
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
|
||||
self.sprite_rotation,
|
||||
self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.sprite_scale.y * self.sprite_flip.y
|
||||
)
|
||||
|
||||
--[[
|
||||
love.graphics.print(self.body.frame .. "/".. self.body.frames.." - "..self.body.subframe.."/"..self.body.speed.." ("..current_dt..")")
|
||||
love.graphics.print(animation.nancy.idle.path,0,20)
|
||||
love.graphics.print(self.body.path,0,30)
|
||||
]]
|
||||
end
|
||||
|
||||
function Player:DoPhysics()
|
||||
|
||||
Reference in New Issue
Block a user