From a9f4d3080389d18a3ebddb5294a2f8ee3c758e5e Mon Sep 17 00:00:00 2001 From: fnicon Date: Mon, 23 Mar 2026 01:49:34 +0900 Subject: [PATCH] Add checkpoint check --- .../src/new/world/race/components/racer.lua | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/game/love_src/src/new/world/race/components/racer.lua b/game/love_src/src/new/world/race/components/racer.lua index 433e17a..4dd62e9 100644 --- a/game/love_src/src/new/world/race/components/racer.lua +++ b/game/love_src/src/new/world/race/components/racer.lua @@ -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()