libraries_setup #3
BIN
game/asset/video/1_intro.ogv
Normal file
BIN
game/asset/video/1_intro.ogv
Normal file
Binary file not shown.
@ -1,36 +1,39 @@
|
|||||||
local world = {
|
local wm = require("world_map")
|
||||||
|
|
||||||
|
world = {
|
||||||
["main_menu"] = require("src.world.main_menu")(),
|
["main_menu"] = require("src.world.main_menu")(),
|
||||||
|
["1_intro"] = require("src.world.1_intro")(),
|
||||||
["race"] = require("src.world.race")(),
|
["race"] = require("src.world.race")(),
|
||||||
["train"] = require("src.world.train")(),
|
["train"] = require("src.world.train")(),
|
||||||
};
|
};
|
||||||
|
|
||||||
local world_i = "main_menu"
|
current = wm["main_menu"]
|
||||||
|
|
||||||
function load_world(world_to_load)
|
function load_world(world_to_load)
|
||||||
world_i = world_to_load
|
current = world_to_load
|
||||||
world[world_i]:reload()
|
world[current]:reload()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
world[world_i]:load()
|
world[current]:load()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
world[world_i]:update(dt)
|
world[current]:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
world[world_i]:draw()
|
world[current]:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keyreleased(key, scancode)
|
function love.keyreleased(key, scancode)
|
||||||
world[world_i]:keyreleased(key, scancode)
|
world[current]:keyreleased(key, scancode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key, scancode, isrepeat)
|
function love.keypressed(key, scancode, isrepeat)
|
||||||
world[world_i]:keypressed(key, scancode, isrepeat)
|
world[current]:keypressed(key, scancode, isrepeat)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousereleased(x, y, button, istouch, presses)
|
function love.mousereleased(x, y, button, istouch, presses)
|
||||||
world[world_i]:mousereleased(x, y, button, istouch, presses)
|
world[current]:mousereleased(x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|||||||
68
game/src/world/1_intro/init.lua
Normal file
68
game/src/world/1_intro/init.lua
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
local reap = require("lib.reap")
|
||||||
|
|
||||||
|
local BASE = reap.base_path(...)
|
||||||
|
|
||||||
|
local world = require("wrapper.Concord.world")
|
||||||
|
|
||||||
|
local debug_entity = require("src.world.common.template.debug_entity")
|
||||||
|
local button = require("src.world.common.template.button")
|
||||||
|
local video = require("src.world.common.template.video")
|
||||||
|
local c_video = require("src.world.common.component.video")
|
||||||
|
local wm = require("world_map")
|
||||||
|
|
||||||
|
local wrapper = world:extend()
|
||||||
|
|
||||||
|
local function button_func()
|
||||||
|
load_world(wm["race"])
|
||||||
|
end
|
||||||
|
|
||||||
|
function wrapper:new()
|
||||||
|
wrapper.super.new(self, BASE, ".1_intro")
|
||||||
|
end
|
||||||
|
|
||||||
|
function wrapper:load(_args)
|
||||||
|
wrapper.super.load(self, {
|
||||||
|
"src/world/common/system/"
|
||||||
|
}, {
|
||||||
|
{
|
||||||
|
assemblage = debug_entity.assembleDebug,
|
||||||
|
data = {
|
||||||
|
position = {0, 0},
|
||||||
|
label = "1_intro"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
assemblage = button.assemble,
|
||||||
|
data = {
|
||||||
|
collider = {
|
||||||
|
x = 20,
|
||||||
|
y = 20,
|
||||||
|
w = 20,
|
||||||
|
h = 20
|
||||||
|
},
|
||||||
|
func = button_func,
|
||||||
|
label = "skip"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
assemblage = video.assemble,
|
||||||
|
data = {
|
||||||
|
path = "asset/video/1_intro.ogv"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function wrapper:update(dt)
|
||||||
|
wrapper.super.update(self, dt)
|
||||||
|
for k, v in pairs(self.entities) do
|
||||||
|
local c_v = v[c_video.dict.video]
|
||||||
|
if c_v ~= nil then
|
||||||
|
if (not c_v.data.video:isPlaying()) then
|
||||||
|
load_world(wm["race"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return wrapper
|
||||||
16
game/src/world/common/component/video.lua
Normal file
16
game/src/world/common/component/video.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
local video = require("wrapper.lappy.new.video").obj
|
||||||
|
|
||||||
|
local components = {}
|
||||||
|
|
||||||
|
components.dict = {
|
||||||
|
video = "video",
|
||||||
|
}
|
||||||
|
|
||||||
|
function components.video (c, path)
|
||||||
|
c.data = {
|
||||||
|
video = video:load_to(path, path),
|
||||||
|
path = path
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return components
|
||||||
50
game/src/world/common/system/video_render.lua
Normal file
50
game/src/world/common/system/video_render.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
local system_constructor = require("wrapper.Concord.system")
|
||||||
|
local c_video = require("src.world.common.component.video")
|
||||||
|
|
||||||
|
local system = {}
|
||||||
|
|
||||||
|
system.__index = system
|
||||||
|
|
||||||
|
system.pool = {
|
||||||
|
pool = {
|
||||||
|
c_video.dict.video,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
system.components = {
|
||||||
|
[c_video.dict.video] = c_video.video,
|
||||||
|
}
|
||||||
|
|
||||||
|
function system.new()
|
||||||
|
local new_system = system_constructor.new("video_render", 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
|
||||||
|
|
||||||
|
function system:load()
|
||||||
|
for _, e in ipairs(self.pool) do
|
||||||
|
video = e[c_video.dict.video].data.video
|
||||||
|
video:play()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function system:update(dt)
|
||||||
|
for _, e in ipairs(self.pool) do
|
||||||
|
video = e[c_video.dict.video].data.video
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function system:draw()
|
||||||
|
for _, e in ipairs(self.pool) do
|
||||||
|
video = e[c_video.dict.video].data.video
|
||||||
|
love.graphics.draw(video, 0, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return system
|
||||||
12
game/src/world/common/template/video.lua
Normal file
12
game/src/world/common/template/video.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
local video = require("src.world.common.component.video")
|
||||||
|
|
||||||
|
local template = {}
|
||||||
|
|
||||||
|
template.default_data = {
|
||||||
|
path = ""
|
||||||
|
}
|
||||||
|
function template.assemble(e, data)
|
||||||
|
e:give(video.dict.video, data.path)
|
||||||
|
end
|
||||||
|
|
||||||
|
return template
|
||||||
@ -6,11 +6,12 @@ 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 button = require("src.world.common.template.button")
|
local button = require("src.world.common.template.button")
|
||||||
|
local wm = require("world_map")
|
||||||
|
|
||||||
local wrapper = world:extend()
|
local wrapper = world:extend()
|
||||||
|
|
||||||
local function button_func()
|
local function button_func()
|
||||||
load_world("race")
|
load_world(wm["1_intro"])
|
||||||
end
|
end
|
||||||
|
|
||||||
function wrapper:new()
|
function wrapper:new()
|
||||||
@ -38,7 +39,7 @@ function wrapper:load(_args)
|
|||||||
h = 20
|
h = 20
|
||||||
},
|
},
|
||||||
func = button_func,
|
func = button_func,
|
||||||
label = "race"
|
label = "play"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
6
game/world_map.lua
Normal file
6
game/world_map.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
["main_menu"] = "main_menu",
|
||||||
|
["1_intro"] = "1_intro",
|
||||||
|
["race"] = "race",
|
||||||
|
["train"] = "train"
|
||||||
|
}
|
||||||
17
game/wrapper/lappy/new/video.lua
Normal file
17
game/wrapper/lappy/new/video.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
local cache = require("lib.reoof.cache")
|
||||||
|
---@class lappy.video : Cache
|
||||||
|
---@field cache any
|
||||||
|
local _cache = cache:extend()
|
||||||
|
|
||||||
|
--- new function
|
||||||
|
function _cache:new()
|
||||||
|
_cache.super.new(self, love.graphics.newVideo, ".video")
|
||||||
|
self.cache = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local obj = _cache()
|
||||||
|
|
||||||
|
return {
|
||||||
|
class = _cache,
|
||||||
|
obj = obj
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user