2021-10-22 16:23:05 +00:00
|
|
|
Entity = {
|
|
|
|
}
|
2021-10-16 23:06:11 +00:00
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
function Entity:New(x,y)
|
2021-10-16 23:06:11 +00:00
|
|
|
o = {}
|
|
|
|
o.pos = {x = x, y = y}
|
2021-10-22 16:23:05 +00:00
|
|
|
o.vel = {x = 0, y = 0}
|
|
|
|
o.class = "Entity"
|
|
|
|
o.anim_subframe = 0
|
|
|
|
o.anim_frame = 0
|
|
|
|
o.anim_imgs = {}
|
|
|
|
o.offset = {x = 0, y = 0}
|
|
|
|
o.scale = {x = 1, y = 1}
|
|
|
|
o.flip = { x = 1, y = 1}
|
2021-10-16 23:06:11 +00:00
|
|
|
setmetatable(o, self)
|
|
|
|
self.__index = self
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
function Entity:Move(target, speed) -- target = {tx int, ty int} / speed = int
|
2021-10-16 23:06:11 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
function Entity:Draw()
|
2021-10-16 23:06:11 +00:00
|
|
|
if self.sprite ~= nil then
|
|
|
|
love.graphics.draw(
|
|
|
|
self.sprite,
|
|
|
|
self.pos.x - Camera.pos.x + self.offset.x * game.scale * self.scale.x * self.flip.x,
|
|
|
|
self.pos.y - Camera.pos.y + self.offset.y * game.scale * self.scale.y * self.flip.y,
|
|
|
|
0,
|
|
|
|
game.scale * self.scale.x * self.flip.x,
|
|
|
|
game.scale * self.scale.y * self.flip.y
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
function Entity:Animate()
|
2021-10-16 23:06:11 +00:00
|
|
|
if game_paused ~= true 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
|
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
function Entity:LoadAnimation(anim,frames,speed)
|
2021-10-16 23:06:11 +00:00
|
|
|
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
|
|
|
|
|
2021-10-22 16:23:05 +00:00
|
|
|
require "data/scripts/entities/kupo"
|
2021-10-16 23:06:11 +00:00
|
|
|
require "data/scripts/entities/player"
|