add time attacks

This commit is contained in:
fnicon 2026-03-23 01:31:16 +09:00
parent 6a300c5b8f
commit e916cf63fa
8 changed files with 115 additions and 8 deletions

View File

@ -26,7 +26,7 @@ function love.conf(t)
t.window.width = 1024
t.window.height = 1024
t.window.borderless = false
t.window.resizable = true
t.window.resizable = false
t.window.minwidth = 10
t.window.minheight = 9
t.window.fullscreen = false

View File

@ -0,0 +1,46 @@
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, "checkpoints")
end
function world:load(entity, data)
self.data = data
self.e = entity
end
function world:update(dt)
-- self.data.label = self.e.components.animation.data.frames[self.e.components.animation.data.current_frame]
end
function world:ui_draw()
-- 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
-- self.data.label = ""
-- uir.draw_text(self.data.label,
-- self.data.pos[1], self.data.pos[2],
-- self.data.label_color
-- )
-- end
end
return world

View File

@ -10,7 +10,7 @@ local reap = require("lib.reap")
local BASE = reap.base_path(...)
function world:new()
world.super.new(self, BASE, "phase")
world.super.new(self, BASE, "countdown")
end

View File

@ -31,7 +31,7 @@ local function debug_data(x, y, r, g, b, to_debug)
end
function world:ui_draw()
debug_data(650, 800, 1.0, 0.0, 1.0, self.data)
-- debug_data(650, 800, 1.0, 0.0, 1.0, self.data)
end
return world

View File

@ -54,6 +54,9 @@ function world:load(entity, data)
self.world_state = {}
self.late_timer = 0
self.time_attacks = {}
self.lap = 1
end
function get(s)
@ -135,7 +138,7 @@ function world:update_race(dt)
if (self.world_state.data.state == "count down") then
else
if (self.late_timer < 1 and not self.initial_boost) then
if (self.late_timer < 1 and not self.initial_boost and f_v > 0) then
f_v = f_v + 0.1
self.initial_boost = true
end
@ -147,11 +150,17 @@ function world:update_race(dt)
-- end
self.data.inertia = force
self.time_attacks[self.lap] = self.time_attacks[self.lap] + dt
end
end
function world:update(dt)
self:update_race(dt)
if (self.time_attacks[self.lap] == nil) then
self.time_attacks[self.lap] = 0
end
end
function world:draw()
@ -162,6 +171,14 @@ function world:draw()
test.set_sphere(x, y, vx, vy)
end
local function draw_time_attack(x, y, r, g, b, to_debug)
local font_ix = test.draw_font_start()
test.draw_font_set_base_color(r, g, b)
for k, v in pairs(to_debug) do
y = y + test.draw_font(font_ix, string.format("%s : %s seconds", k, v), x, y)
end
end
local function debug_data(x, y, r, g, b, to_debug)
local font_ix = test.draw_font_start()
test.draw_font_set_base_color(r, g, b)
@ -179,11 +196,14 @@ local function debug_vector(vx, vy)
end
function world:ui_draw()
debug_data(650, 0, 1.0, 0.0, 1.0, self.data)
debug_data(650, 400, 1.0, 0.0, 1.0, magic_w)
local lw, lh = love.graphics.getDimensions()
draw_time_attack(lw/2, 20, 1.0, 0.0, 1.0, self.time_attacks)
-- debug_data(650, 0, 1.0, 0.0, 1.0, self.data)
-- debug_data(650, 400, 1.0, 0.0, 1.0, magic_w)
local vx, vy = self.data.orientation[1], self.data.orientation[2]
debug_vector(vx, vy)
-- debug_vector(vx, vy)
end
return world

View File

@ -6,7 +6,7 @@ return {
{
components = {
racer = require("love_src.src.new.world.race.components.racer"),
actor = require("love_src.src.new.world.race.components.actor"),
actor = require("love_src.src.new.world.race.components.player"),
},
type = "racer",
name = "racer 1",
@ -95,5 +95,42 @@ return {
}
}
}
},
{
type = "checkpoints",
name = "checkpoints",
components = {
checkpoints = require"love_src.src.new.world.race.components.checkpoints"
},
data = {
checkpoints = {
label = "",
pos = vm.vec2(lw - 50, 0),
label_color = {1, 1, 0},
check = {
{
pos = vm.vec2(80, 8),
wh = vm.vec2(10, 10)
},
{
pos = vm.vec2(115, 23),
wh = vm.vec2(10, 10)
},
{
pos = vm.vec2(12, 55),
wh = vm.vec2(10, 10)
},
{
pos = vm.vec2(-23, 28),
wh = vm.vec2(10, 10)
},
{
pos = vm.vec2(40, 7), -- finish line
wh = vm.vec2(10, 10)
}
},
max_lap = 3
}
}
}
}

View File

@ -107,6 +107,7 @@ end
function world:setup()
local map
local countdown
local checkpoints
self.world_state = {}
for _, d in pairs(self.entities_data) do
local e = {
@ -125,6 +126,8 @@ function world:setup()
self.world_state = e
elseif e.type == "countdown" then
countdown = e
elseif e.type == "checkpoints" then
checkpoints = e
end
end
for _, e in ipairs(self.entities) do
@ -132,6 +135,7 @@ function world:setup()
e.components.racer.map = map.components.map
e.components.racer.countdown = countdown.components.countdown
e.components.racer.world_state = self.world_state.components.world_state
e.components.racer.checkpoints = checkpoints.components.checkpoints
elseif (e.type == "countdown") then
e.components.countdown:load_world_state(self.world_state.components.world_state)
end