libraries_setup #3

Merged
fnicon merged 13 commits from libraries_setup into main 2026-03-18 14:29:14 +00:00
28 changed files with 235 additions and 2 deletions
Showing only changes of commit 81fb06cc88 - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

View File

@ -0,0 +1,49 @@
local image = require("wrapper.lappy.new.image").obj
local components = {}
components.dict = {
image_frame = "image_frame",
trigger_frame = "trigger_frame",
frame_i = "frame_i",
run_time = "run_time",
anim_direction = "anim_direction",
next_trigger_frame = "next_trigger_frame",
fps = "fps"
}
function components.image_frame (c, paths)
c.data = {
images = {},
path = paths or {}
}
for k, v in ipairs(paths) do
table.insert(c.data.images, image:load_to(v, v))
end
end
function components.trigger_frame (c, array)
c.data = array or {}
end
function components.frame_i (c, index)
c.data = index or 1
end
function components.run_time (c, float)
c.data = float or 0
end
function components.anim_direction (c, one)
c.data = one or 1
end
function components.next_trigger_frame (c, index)
c.data = index or 1
end
function components.fps (c, frame_per_second)
c.data = frame_per_second or 12
end
return components

View File

@ -0,0 +1,24 @@
local source = require("wrapper.lappy.new.source").obj
local components = {}
components.dict = {
bgm = "bgm",
sfx = "sfx",
}
function components.bgm (c, path)
c.data = {
source = source:load_to(path, path, "stream"),
path = path
}
end
function components.sfx (c, path)
c.data = {
source = source:load_to(path, path, "static"),
path = path
}
end
return components

View File

@ -0,0 +1,97 @@
local floor = math.floor
local system_constructor = require("wrapper.Concord.system")
local audio = require("src.world.common.component.audio")
local animation = require("src.world.common.component.animation")
local system = {}
system.__index = system
system.pool = {
pool = {
audio.dict.sfx,
animation.dict.anim_direction,
animation.dict.fps,
animation.dict.frame_i,
animation.dict.image_frame,
animation.dict.next_trigger_frame,
animation.dict.run_time,
animation.dict.trigger_frame,
}
}
system.components = {
[audio.dict.sfx] = audio.sfx,
[animation.dict.anim_direction] = animation.anim_direction,
[animation.dict.fps] = animation.fps,
[animation.dict.frame_i] = animation.frame_i,
[animation.dict.image_frame] = animation.image_frame,
[animation.dict.next_trigger_frame] = animation.next_trigger_frame,
[animation.dict.run_time] = animation.run_time,
[animation.dict.trigger_frame] = animation.trigger_frame,
}
function system.new()
local new_system = system_constructor.new("flip", system.pool)
if (new_system) then
for k, v in pairs(system) do
new_system[k] = v
end
return new_system
else
return nil
end
end
--- system frame
local function update_time(time, delta, indicator)
return time + (delta * indicator)
end
local function get_loop(index, _max)
local md = index % _max
if (md == 0) then
return _max
else
return index % _max
end
end
local function update_fps_time(time, fps)
-- floor time to 1. check x fps per second
return floor(time / (1 / fps))
end
-- system trigger frame
local function is_trigger(trigger_frames, trigger_id, frame_id)
return (trigger_frames[trigger_id] == frame_id)
end
function system:update(dt)
for _, e in ipairs(self.pool) do
e[animation.dict.run_time].data = update_time(
e[animation.dict.run_time].data, dt, e[animation.dict.anim_direction].data
)
local new_index = update_fps_time(
e[animation.dict.run_time].data, e[animation.dict.fps].data
)
e[animation.dict.frame_i].data = get_loop(
new_index,
#e[animation.dict.image_frame].data.images
)
if (is_trigger(
e[animation.dict.trigger_frame].data,
e[animation.dict.next_trigger_frame].data,
e[animation.dict.frame_i].data
)) then
e[animation.dict.next_trigger_frame].data = get_loop(
e[animation.dict.next_trigger_frame].data + 1, #e[animation.dict.trigger_frame].data
)
e[audio.dict.sfx].data.source:play()
end
end
end
return system

View File

@ -0,0 +1,39 @@
local flip = require("src.world.common.system.flip")
local template = {}
template.default_data = {
sfx = "asset/audio/sfx/book_flip.1.ogg",
anim_direction = 1,
fps = 12,
frame_i = 1,
image_frame = {
"asset/image/book/StoryMode.png",
"asset/image/book/StoryModeBook.png",
"asset/image/book/StoryModeBook2.png",
"asset/image/book/StoryModeBook3.png",
"asset/image/book/StoryModeBook4.png",
"asset/image/book/StoryModeBook5.png",
"asset/image/book/StoryModeBook6.png",
"asset/image/book/StoryModeBook7.png",
"asset/image/book/StoryModeBook8.png",
"asset/image/book/StoryModeBook9.png",
"asset/image/book/StoryModeBook11.png",
"asset/image/book/StoryModeBook16.png",
},
next_trigger_frame = 1,
run_time = 0,
trigger_frame = {1},
}
function template.assemble(e, data)
e:give(flip.pool.pool[1], data.sfx)
e:give(flip.pool.pool[2], data.anim_direction)
e:give(flip.pool.pool[3], data.fps)
e:give(flip.pool.pool[4], data.frame_i)
e:give(flip.pool.pool[5], data.image_frame)
e:give(flip.pool.pool[6], data.next_trigger_frame)
e:give(flip.pool.pool[7], data.run_time)
e:give(flip.pool.pool[8], data.trigger_frame)
end
return template

View File

@ -1,10 +1,14 @@
local reap = require("lib.reap") local reap = require("lib.reap")
local BASE = reap.base_path(...) local BASE = reap.base_path(...)
local image = require("wrapper.lappy.new.image").obj
local world = require("wrapper.Concord.world") local world = require("wrapper.Concord.world")
local debug_entity = require("src.world.common.template.debug_entity") local debug_entity = require("src.world.common.template.debug_entity")
local book = require("src.world.common.template.book")
local animation = require("src.world.common.component.animation")
local wrapper = world:extend() local wrapper = world:extend()
@ -22,8 +26,26 @@ function wrapper:load(_args)
position = {0, 0}, position = {0, 0},
label = "race world" label = "race world"
} }
},
{
assemblage = book.assemble,
data = book.default_data
} }
}) })
end end
function wrapper:draw()
wrapper.super.draw(self)
for k, v in pairs(self.entities) do
if v[animation.dict.frame_i] ~= nil then
local frame_i = v[animation.dict.frame_i].data
local img = v[animation.dict.image_frame].data.images
if (img ~= nil) then
love.graphics.draw(img[frame_i])
end
end
end
end
return wrapper return wrapper

View File

@ -22,6 +22,7 @@ function wrapper:new(path, name)
wrapper.super.new(self, path, name) wrapper.super.new(self, path, name)
self.is_loaded = false self.is_loaded = false
self.world = World() self.world = World()
self.entities = {}
end end
local function load_systems(world, system_paths) local function load_systems(world, system_paths)
@ -46,17 +47,18 @@ local function load_systems(world, system_paths)
end end
end end
local function load_entities(world, data) local function load_entities(self, world, data)
for _, d in pairs(data) do for _, d in pairs(data) do
local entity = entity_builder.new() local entity = entity_builder.new()
entity:assemble(d.assemblage, d.data) entity:assemble(d.assemblage, d.data)
world:addEntity(entity) world:addEntity(entity)
table.insert(self.entities, entity)
end end
end end
function wrapper:load(system_paths, entities_data) function wrapper:load(system_paths, entities_data)
load_systems(self.world, system_paths) load_systems(self.world, system_paths)
load_entities(self.world, entities_data) load_entities(self, self.world, entities_data)
self.is_loaded = true self.is_loaded = true
self.world:emit("load") self.world:emit("load")
end end