- More cleanup

- Added kupos entity and sprites (body, bow)
- Finally understood my code
This commit is contained in:
lustlion
2021-10-22 18:23:05 +02:00
parent 966aebf046
commit 5b7924fe4e
157 changed files with 394 additions and 1159 deletions

View File

@@ -1,19 +1,27 @@
entity = {class = "entity", anim_subframe = 0, anim_frame = 0, anim_imgs = {}, offset = {x = 0, y = 0}, scale = {x = 1, y = 1}, flip = { x = 1, y = 1}}
Entity = {
}
function entity:newEntity(x,y)
function Entity:New(x,y)
o = {}
o.pos = {x = x, y = y}
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}
setmetatable(o, self)
self.__index = self
return o
end
function entity:Move(target, speed) -- target = {tx int, ty int} / speed = int
function Entity:Move(target, speed) -- target = {tx int, ty int} / speed = int
end
function entity:Draw()
function Entity:Draw()
if self.sprite ~= nil then
love.graphics.draw(
self.sprite,
@@ -26,7 +34,7 @@ function entity:Draw()
end
end
function entity:Animate()
function Entity:Animate()
if game_paused ~= true then
-- try to animate
self.anim_subframe = self.anim_subframe + current_dt
@@ -46,7 +54,7 @@ function entity:Animate()
end
end
function entity:LoadAnimation(anim,frames,speed)
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
@@ -62,4 +70,5 @@ function entity:LoadAnimation(anim,frames,speed)
end
end
require "data/scripts/entities/kupo"
require "data/scripts/entities/player"