Add checkpoint check

This commit is contained in:
fnicon 2026-03-23 01:49:34 +09:00
parent e916cf63fa
commit a9f4d30803

View File

@ -1,5 +1,7 @@
local vm = require"lib.vornmath"
local racing_force = require("love_src.src.system.racing_force")
local uib = require"love_src.src.system.ui_behavior"
local get_loop = require"love_src.src.system.animation".get_loop
local main_wrapper = require "love_src.wrapper.lappy.world"
---@class wrappers.Concord.world : lappy.world
@ -57,6 +59,9 @@ function world:load(entity, data)
self.time_attacks = {}
self.lap = 1
self.current_cp = 1
self.checkpoints = {}
end
function get(s)
@ -107,6 +112,15 @@ local function orientation_velocity(dt, force, mass, orientation_speed, orientat
return new_orientation, new_speed
end
function world:update_checkpoint(dt)
local cp = self.checkpoints.data.check[self.current_cp]
local is_inside_cp = uib.is_inside(cp.pos[1], cp.pos[2], cp.wh[1], cp.wh[2], self.data.pos[1], self.data.pos[2])
if (is_inside_cp) then
self.current_cp = get_loop(self.current_cp + 1, #self.checkpoints.data.check)
end
print(self.current_cp)
end
function world:update_race(dt)
local x, y = self.data.pos[1], self.data.pos[2]
local or_x, or_y = self.data.orientation[1], self.data.orientation[2]
@ -150,17 +164,24 @@ function world:update_race(dt)
-- end
self.data.inertia = force
end
end
function world:update_time_attack(dt)
if (self.time_attacks[self.lap] == nil) then
self.time_attacks[self.lap] = 0
end
if (self.world_state.data.state == "count down") then
else
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
self:update_time_attack(dt)
self:update_checkpoint(dt)
end
function world:draw()