Created Particles, added fairy particle, added more entity methods like kill() and entity id

This commit is contained in:
lustlion 2022-01-19 23:29:02 +01:00
parent 15e8142c4c
commit 50f126fa7b
77 changed files with 106 additions and 26 deletions

View File

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View File

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 190 B

View File

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

View File

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 190 B

View File

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 190 B

View File

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

View File

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

View File

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

View File

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 195 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 203 B

View File

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View File

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View File

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 107 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

View File

@ -17,9 +17,11 @@ Arrow = Entity:New(x,y)
-- animations
o.body = Animation:New(animation.kupo.arrow)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
table.insert(LoadedEntities,o)
return o
end

View File

@ -15,11 +15,13 @@ function Decoration:New(x,y,animation,lightRange)
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange,nil,60/6)
end
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
return o
end
end
function Decoration:Smart()
end

View File

@ -17,9 +17,11 @@ Fairy = Entity:New(x,y)
o.lightRange = 55
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
return o
end
@ -31,8 +33,8 @@ function Fairy:Smart()
self.target.y = main_Player.pos.y - main_Player.target_offset.y - 10
local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
if distance < self.range then
self.vel.x = 0
self.vel.y = 0
@ -40,6 +42,7 @@ function Fairy:Smart()
self.vel.x = math.cos(angle)*self.speed*distance/(8*game.scale)
self.vel.y = math.sin(angle)*self.speed*distance/(8*game.scale)
end
Particle:New(self.pos.x,self.pos.y,animation.particle.fairy,angle-math.rad(180),self.speed*distance/(16*game.scale))
end
function Fairy:HandleAnimation()

View File

@ -28,9 +28,11 @@ Kupo = Entity:New(x,y)
o.lightRange = o.range/2
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
return o
end

View File

@ -0,0 +1,48 @@
Particle = Entity:New(x,y)
function Particle:New(x,y,animation,rotation,speed)
local o = Entity:New(x,y)
o.pos = {x = x, y = y}
o.speed = speed or 0
o.sprite_rotation = rotation or 0
o.time = 0.5
o.timer = 0
o.vel = {
x = o.speed * math.cos(o.sprite_rotation),
y = o.speed * math.sin(o.sprite_rotation)
}
-- animations
o.body = Animation:New(animation)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
return o
end
function Particle:Smart()
end
function Particle:HandleAnimation()
self.body:Animate()
self.timer = self.timer + current_dt
self.sprite_alpha = (self.time-self.timer)/self.time
if self.sprite_alpha < 0 then self:Kill() end
self:Draw(self.body)
end
function Particle:DoPhysics()
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, objects.collisions) then
self.pos.x = self.pos.x + self.vel.x
end
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, objects.collisions) then
self.pos.y = self.pos.y + self.vel.y
end
end

View File

@ -53,9 +53,11 @@
-- lights
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
setmetatable(o, self)
self.__index = self
return o
end

View File

@ -15,11 +15,13 @@ function Entity:New(x,y)
o.sprite_scale = {x = 1, y = 1}
o.sprite_rotation = math.rad(0)
o.sprite_tint = {1,1,1}
o.sprite_alpha = 1
o.sprite_flip = { x = 1, y = 1}
o.illuminated = false
setmetatable(o, self)
self.__index = self
return o
end
@ -43,7 +45,7 @@ end
function Entity:Draw(animation)
local c1, c2, c3, a = love.graphics.getColor()
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3])
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
animation: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,
@ -88,8 +90,21 @@ function Entity:isCollidingAtAll(x,y)
return result
end
function Entity:Kill()
if self.id ~= nil then
for _, e in pairs(LoadedEntities) do
if e.id > self.id then
e.id = e.id - 1
end
end
table.remove(LoadedEntities,self.id)
end
self = nil
end
require "data/scripts/entities/kupo"
require "data/scripts/entities/arrow"
require "data/scripts/entities/decoration"
require "data/scripts/entities/player"
require "data/scripts/entities/fairy"
require "data/scripts/entities/particle"

View File

@ -1,77 +1,84 @@
-- animationsç
-- all these are linear animations, maybe in the future make proper animations?
animation = {
particle = {
fairy = {
path = "assets/entities/particle/fairy",
frames = 4,
speed = 1/4
}
},
fairy = {
flying = {
path = "assets/characters/fairy/flying",
path = "assets/entities/fairy/flying",
frames = 2,
speed = 1/30
}
},
decoration = {
candelabra = {
path = "assets/characters/decoration/candelabra",
path = "assets/entities/decoration/candelabra",
frames = 8,
speed = 1/6
}
},
kupo = {
body = {
path = "assets/characters/kupo/kupo",
path = "assets/entities/kupo/kupo",
frames = 4,
speed = 1/8
},
bow = {
path = "assets/characters/kupo/kupo_bow",
path = "assets/entities/kupo/kupo_bow",
frames = 6,
speed = 1/10
},
arrow = {
path = "assets/characters/kupo/kupo_arrow",
path = "assets/entities/kupo/kupo_arrow",
frames = 1,
speed = 1
}
},
moth_mask = {
idle = {
path = "assets/characters/nancy/moth_mask/idle",
path = "assets/entities/nancy/moth_mask/idle",
frames = 4,
speed = 1/8
},
run = {
path = "assets/characters/nancy/moth_mask/run",
path = "assets/entities/nancy/moth_mask/run",
frames = 6,
speed = 1/8
},
fall = {
path = "assets/characters/nancy/moth_mask/fall",
path = "assets/entities/nancy/moth_mask/fall",
frames = 3,
speed = 1/8
},
jump = {
path = "assets/characters/nancy/moth_mask/jump",
path = "assets/entities/nancy/moth_mask/jump",
frames = 3,
speed = 1/8
}
},
nancy = {
idle = {
path = "assets/characters/nancy/idle",
path = "assets/entities/nancy/idle",
frames = 4,
speed = 1/8
},
run = {
path = "assets/characters/nancy/run",
path = "assets/entities/nancy/run",
frames = 6,
speed = 1/8
},
fall = {
path = "assets/characters/nancy/fall",
path = "assets/entities/nancy/fall",
frames = 3,
speed = 1/8
},
jump = {
path = "assets/characters/nancy/jump",
path = "assets/entities/nancy/jump",
frames = 3,
speed = 1/8
}

View File

@ -43,11 +43,10 @@ function love.load()
main_Player = Player:New(75,50)
table.insert(LoadedEntities,main_Player)
table.insert(LoadedEntities,Kupo:New(100,150))
table.insert(LoadedEntities,Kupo:New(300,150))
table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80))
table.insert(LoadedEntities,Fairy:New(200,88))
Kupo:New(100,150)
Kupo:New(300,150)
Decoration:New(200,89,animation.decoration.candelabra,80)
Fairy:New(200,88)
gravity = 0.2
end