add countdown and track1 data

This commit is contained in:
fnicon 2026-03-23 00:19:20 +09:00
parent 3e9f16dfbd
commit 5c2aa31153
5 changed files with 168 additions and 6 deletions

View File

@ -13,20 +13,46 @@ function world:new()
world.super.new(self, BASE, "phase")
end
function world:load(entity, data)
self.data = data
self.e = entity
end
function world:load_world_state(world_state)
self.e.components.animation.data.triggers_fn[4] = function ()
if (not self.disappear) then
world_state.components.world_state.data.state = "START"
self.e.components.animation.data.anim_direction = 0
self.disappear = 2
end
end
end
function world:update(dt)
if (self.disappear) then
self.disappear = self.disappear - dt
end
self.data.label = self.e.components.animation.data.frames[self.e.components.animation.data.current_frame]
end
function world:ui_draw()
uir.draw_text(self.data.label,
self.data.pos[1], self.data.pos[2],
self.data.label_color
)
if (not self.disappear) then
uir.draw_text(self.data.label,
self.data.pos[1], self.data.pos[2],
self.data.label_color
)
elseif (self.disappear and self.disappear > 0) then
uir.draw_text(self.data.label,
self.data.pos[1], self.data.pos[2],
self.data.label_color
)
else
uir.draw_text("",
self.data.pos[1], self.data.pos[2],
self.data.label_color
)
end
end
return world

View File

@ -0,0 +1,32 @@
local vm = require"lib.vornmath"
local uib = require"love_src.src.system.ui_behavior"
local uir = require"love_src.src.system.ui_render"
local main_wrapper = require "love_src.wrapper.lappy.world"
---@class wrappers.Concord.world : lappy.world
local world = main_wrapper:extend()
local reap = require("lib.reap")
local BASE = reap.base_path(...)
function world:new()
world.super.new(self, BASE, "phase")
end
function world:load(entity, data)
self.data = data
self.e = entity
end
function world:next_state(state)
self.data.state = state
end
function world:ui_draw()
uir.draw_text(self.data.state,
self.data.pos[1], self.data.pos[2],
self.data.label_color
)
end
return world

View File

@ -0,0 +1,99 @@
local vm = require"lib.vornmath"
local lw, lh = love.graphics.getDimensions()
return {
{
components = {
racer = require("love_src.src.new.world.race.components.racer"),
actor = require("love_src.src.new.world.race.components.actor"),
},
type = "racer",
name = "racer 1",
data = {
racer = {
pos = vm.vec2(44.64, 10.87),
orientation = vm.vec2(1.0, 0.0),
orientation_speed = 0.0,
min_orientation_speed = -1.0,
max_orientation_speed = 1.0,
velocity = vm.vec2(0.0, 0.0),
max_speed = 0.3,
min_speed = -0.3,
inertia = vm.vec2(0.0, 0.0),
accel = 0.1,
brake = 0.1,
grip = 0.1,
steer = 0.01,
mass = 0.1,
streamline = 0.1
},
actor = {
forward = 0.0,
steer = 0.0,
}
}
},
{
components = {
map = require"love_src.src.new.world.race.components.map"
},
type = "map",
name = "map 1",
data = {
map = {
drag_movement = 0.1,
friction = 0.1,
drag = vm.vec2(0.1, 0.0)
}
}
},
{
type = "world_state",
name = "race_state",
components = {
world_state = require("love_src.src.new.world.race.components.world_state"),
},
data = {
world_state = {
state = "count down",
pos = vm.vec2(lw/2, lh - 50),
label_color = {1, 0, 1}
}
}
},
{
type = "countdown",
name = "321go",
components = {
countdown = require("love_src.src.new.world.race.components.countdown"),
animation = require("love_src.src.new.shared.components.animation"),
},
data = {
countdown = {
label = "",
pos = vm.vec2(lw/2, lh/2),
label_color = {1, 0, 1}
},
animation = {
frames = {
"3",
"2",
"1",
"go",
""
},
fps = 1,
triggers = {4},
triggers_fn = {
[4] = function ()
print("GO")
end
}
}
}
}
}

View File

@ -106,6 +106,7 @@ end
function world:setup()
local map
self.world_state = {}
for _, d in pairs(self.entities_data) do
local e = {
type = d.type,
@ -119,6 +120,8 @@ function world:setup()
table.insert(self.entities, e)
if (e.type == "map") then
map = e
elseif e.type == "world_state" then
self.world_state = e
end
end
for _, e in ipairs(self.entities) do
@ -128,6 +131,8 @@ function world:setup()
c.map = map.components.map
end
end
elseif (e.type == "countdown") then
e.components.countdown:load_world_state(self.world_state)
end
end
end

View File

@ -215,8 +215,8 @@ local world_data = {
},
["track_1"] = {
world = require("love_src.src.new.world.race.init")(),
-- data = {},
-- entities_data = require("love_src.src.new.world.main_menu.data.track_choose"),
data = {},
entities_data = require("love_src.src.new.world.race.data.track1"),
},
["track_2"] = {
world = require("love_src.src.new.world.race.init")(),