diff --git a/game/conf.lua b/game/conf.lua index 0608c0c..7c90b0f 100644 --- a/game/conf.lua +++ b/game/conf.lua @@ -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 diff --git a/game/love_src/src/new/world/race/components/checkpoint.lua b/game/love_src/src/new/world/race/components/checkpoint.lua deleted file mode 100644 index e69de29..0000000 diff --git a/game/love_src/src/new/world/race/components/checkpoints.lua b/game/love_src/src/new/world/race/components/checkpoints.lua new file mode 100644 index 0000000..d5529cf --- /dev/null +++ b/game/love_src/src/new/world/race/components/checkpoints.lua @@ -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 diff --git a/game/love_src/src/new/world/race/components/countdown.lua b/game/love_src/src/new/world/race/components/countdown.lua index c681952..f85edb1 100644 --- a/game/love_src/src/new/world/race/components/countdown.lua +++ b/game/love_src/src/new/world/race/components/countdown.lua @@ -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 diff --git a/game/love_src/src/new/world/race/components/map.lua b/game/love_src/src/new/world/race/components/map.lua index 6c752d1..501c29b 100644 --- a/game/love_src/src/new/world/race/components/map.lua +++ b/game/love_src/src/new/world/race/components/map.lua @@ -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 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 838f346..433e17a 100644 --- a/game/love_src/src/new/world/race/components/racer.lua +++ b/game/love_src/src/new/world/race/components/racer.lua @@ -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 diff --git a/game/love_src/src/new/world/race/data/track1.lua b/game/love_src/src/new/world/race/data/track1.lua index cecc1cf..d5c5758 100644 --- a/game/love_src/src/new/world/race/data/track1.lua +++ b/game/love_src/src/new/world/race/data/track1.lua @@ -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 + } + } } } diff --git a/game/love_src/src/new/world/race/init.lua b/game/love_src/src/new/world/race/init.lua index 15a1c3f..adcdd22 100644 --- a/game/love_src/src/new/world/race/init.lua +++ b/game/love_src/src/new/world/race/init.lua @@ -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