Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 920 B |
Before Width: | Height: | Size: 184 B After Width: | Height: | Size: 923 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 922 B |
Before Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 919 B |
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 918 B |
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 919 B |
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 917 B |
Before Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 916 B |
Before Width: | Height: | Size: 921 B After Width: | Height: | Size: 919 B |
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 890 B |
Before Width: | Height: | Size: 409 B |
Before Width: | Height: | Size: 914 B After Width: | Height: | Size: 914 B |
Before Width: | Height: | Size: 916 B After Width: | Height: | Size: 915 B |
Before Width: | Height: | Size: 922 B After Width: | Height: | Size: 917 B |
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 919 B |
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 913 B |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 916 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,127 @@
|
||||||
|
function Animation:Draw()
|
||||||
|
if self.sprite ~= nil then
|
||||||
|
local relative_position_x = self.pos.x - Camera.pos.x
|
||||||
|
local relative_position_y = self.pos.y - Camera.pos.y
|
||||||
|
local origin_compensation_x = - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation))
|
||||||
|
local origin_compensation_y = - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation))
|
||||||
|
local dimensions_x = self.sprite_scale.x * self.sprite_flip.x
|
||||||
|
local dimensions_y = self.sprite_scale.y * self.sprite_flip.y
|
||||||
|
love.graphics.draw(
|
||||||
|
self.sprite,
|
||||||
|
relative_position_x + origin_compensation_x * dimensions_x,
|
||||||
|
relative_position_y + origin_compensation_y * dimensions_y,
|
||||||
|
self.sprite_rotation,
|
||||||
|
self.sprite_scale.x * self.sprite_flip.x,
|
||||||
|
self.sprite_scale.y * self.sprite_flip.y
|
||||||
|
)
|
||||||
|
if debug_collision then
|
||||||
|
love.graphics.setColor(1, 0, 0)
|
||||||
|
love.graphics.circle( "line", relative_position_x, relative_position_y, 2 )
|
||||||
|
love.graphics.setColor(0, 1 ,0)
|
||||||
|
love.graphics.circle( "line",
|
||||||
|
relative_position_x + origin_compensation_x * dimensions_x,
|
||||||
|
relative_position_y + origin_compensation_y * dimensions_y,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
end
|
||||||
|
love.graphics.setColor(1, 1 ,1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Animation:New(anim,frames,speed)
|
||||||
|
local anim_data = {
|
||||||
|
frame = 1,
|
||||||
|
subframe = 1,
|
||||||
|
path = anim.path,
|
||||||
|
frames = anim.frames,
|
||||||
|
speed = anim.speed,
|
||||||
|
imgs = anim.imgs
|
||||||
|
}
|
||||||
|
self.animations[#self.animations+1] = anim_data
|
||||||
|
|
||||||
|
return self.animations[#self.animations]
|
||||||
|
end
|
||||||
|
|
||||||
|
function DrawAnimationFrame(animation, frame, x, y, rotate, sx, sy)
|
||||||
|
local x = x or 0
|
||||||
|
local y = y or 0
|
||||||
|
local sx = sx or 1
|
||||||
|
local sy = sy or 1
|
||||||
|
love.graphics.draw(
|
||||||
|
animation.imgs[frame],
|
||||||
|
x - Camera.pos.x,
|
||||||
|
y - Camera.pos.y,
|
||||||
|
rotate,
|
||||||
|
sx,
|
||||||
|
sy
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DrawAnimation(animation, x, y, rotate, sx, sy)
|
||||||
|
local x = x or 0
|
||||||
|
local y = y or 0
|
||||||
|
local sx = sx or 1
|
||||||
|
local sy = sy or 1
|
||||||
|
if game_paused ~= true then
|
||||||
|
-- try to animate
|
||||||
|
animation.subframe = animation.subframe + current_dt
|
||||||
|
|
||||||
|
if animation.subframe >= animation.speed then
|
||||||
|
animation.frame = animation.frame + 1
|
||||||
|
animation.subframe = animation.subframe - animation.speed
|
||||||
|
end
|
||||||
|
|
||||||
|
-- cycle
|
||||||
|
if animation.frame >= animation.frames+1 then
|
||||||
|
animation.frame = animation.frame - animation.frames
|
||||||
|
end
|
||||||
|
end
|
||||||
|
love.graphics.draw(
|
||||||
|
animation.imgs[animation.frame],
|
||||||
|
x - Camera.pos.x,
|
||||||
|
y - Camera.pos.y,
|
||||||
|
rotate,
|
||||||
|
sx,
|
||||||
|
sy
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Entity:Animate()
|
||||||
|
if game_paused ~= true and self.anim.path ~= nil then
|
||||||
|
-- try to animate
|
||||||
|
self.anim.subframe = self.anim.subframe + current_dt
|
||||||
|
|
||||||
|
if self.anim.subframe >= self.anim.speed then
|
||||||
|
self.anim.frame = self.anim.frame + 1
|
||||||
|
self.anim.subframe = self.anim.subframe - self.anim.speed
|
||||||
|
end
|
||||||
|
|
||||||
|
-- cycle
|
||||||
|
if self.anim.frame >= self.anim.frames+1 then
|
||||||
|
self.anim.frame = self.anim.frame - self.anim.frames
|
||||||
|
end
|
||||||
|
|
||||||
|
-- change
|
||||||
|
self.sprite = self.anim.imgs[self.anim.frame]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Entity:LoadAnimation(anim,frames,speed)
|
||||||
|
if self.anim.path ~= anim and self.anim.path ~= anim.path then
|
||||||
|
if frames ~= nil and speed ~= nil then
|
||||||
|
self.anim.path = anim or nil
|
||||||
|
self.anim.frames = frames or 4
|
||||||
|
self.anim.speed = speed or frames
|
||||||
|
else
|
||||||
|
self.anim.path = anim.path
|
||||||
|
self.anim.frames = anim.frames
|
||||||
|
self.anim.speed = anim.speed
|
||||||
|
end
|
||||||
|
|
||||||
|
self.anim.imgs = anim.imgs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require "data/scripts/entities/kupo"
|
||||||
|
require "data/scripts/entities/arrow"
|
||||||
|
require "data/scripts/entities/player"
|
|
@ -37,7 +37,6 @@
|
||||||
o.target_offset = {x = 0, y = 12}
|
o.target_offset = {x = 0, y = 12}
|
||||||
|
|
||||||
-- lights
|
-- lights
|
||||||
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
|
|
||||||
|
|
||||||
|
|
||||||
setmetatable(o, self)
|
setmetatable(o, self)
|
||||||
|
@ -86,9 +85,6 @@ function Player:Smart()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:HandleAnimation()
|
function Player:HandleAnimation()
|
||||||
-- move light to position, :D
|
|
||||||
self.light.pos.x = self.pos.x - self.target_offset.x
|
|
||||||
self.light.pos.y = self.pos.y - self.target_offset.y
|
|
||||||
|
|
||||||
-- flip sprite to look in the direction is moving
|
-- 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
|
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
|
||||||
|
|
|
@ -17,6 +17,28 @@ animation = {
|
||||||
speed = 1
|
speed = 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
nancy_moth_mask = {
|
||||||
|
idle = {
|
||||||
|
path = "assets/characters/nancy/moth_mask/idle",
|
||||||
|
frames = 4,
|
||||||
|
speed = 1/8
|
||||||
|
},
|
||||||
|
run = {
|
||||||
|
path = "assets/characters/nancy/moth_mask/run",
|
||||||
|
frames = 6,
|
||||||
|
speed = 1/8
|
||||||
|
},
|
||||||
|
fall = {
|
||||||
|
path = "assets/characters/nancy/moth_mask/fall",
|
||||||
|
frames = 3,
|
||||||
|
speed = 1/8
|
||||||
|
},
|
||||||
|
jump = {
|
||||||
|
path = "assets/characters/nancy/moth_mask/jump",
|
||||||
|
frames = 3,
|
||||||
|
speed = 1/8
|
||||||
|
}
|
||||||
|
},
|
||||||
nancy = {
|
nancy = {
|
||||||
idle = {
|
idle = {
|
||||||
path = "assets/characters/nancy/idle",
|
path = "assets/characters/nancy/idle",
|
||||||
|
|
|
@ -24,7 +24,7 @@ function SetDarkness()
|
||||||
end
|
end
|
||||||
|
|
||||||
function DoDarkness()
|
function DoDarkness()
|
||||||
love.graphics.setColor(0,0,0,0.3)
|
love.graphics.setColor(0,0,0,1)
|
||||||
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ function DoLights()
|
||||||
if LightTimer >= 3 then
|
if LightTimer >= 3 then
|
||||||
LightTimer = LightTimer - 3
|
LightTimer = LightTimer - 3
|
||||||
for _, light in pairs(Lights) do
|
for _, light in pairs(Lights) do
|
||||||
light.flicker = math.random(-2,2)
|
light.flicker = math.random(-1,1)
|
||||||
light.dim = (light.range+light.flicker)/5
|
light.dim = (light.range+light.flicker)/2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|