add multiple racers
This commit is contained in:
parent
c84cf41222
commit
8957b4427c
@ -65,6 +65,8 @@ function world:load(entity, data)
|
|||||||
self.checkpoints = {}
|
self.checkpoints = {}
|
||||||
|
|
||||||
self.is_finish = false
|
self.is_finish = false
|
||||||
|
|
||||||
|
self.show_pov = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function get(s)
|
function get(s)
|
||||||
@ -199,7 +201,9 @@ function world:draw()
|
|||||||
local or_x, or_y = self.data.orientation[1], self.data.orientation[2]
|
local or_x, or_y = self.data.orientation[1], self.data.orientation[2]
|
||||||
local vx, vy = self.data.orientation[1] * self.data.velocity[1], self.data.orientation[2] * self.data.velocity[1]
|
local vx, vy = self.data.orientation[1] * self.data.velocity[1], self.data.orientation[2] * self.data.velocity[1]
|
||||||
|
|
||||||
|
if (self.show_pov) then
|
||||||
test.set_sphere(x, y, vx, vy)
|
test.set_sphere(x, y, vx, vy)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw_time_attack(x, y, r, g, b, to_debug)
|
local function draw_time_attack(x, y, r, g, b, to_debug)
|
||||||
|
|||||||
@ -37,6 +37,40 @@ 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 2",
|
||||||
|
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 = {
|
components = {
|
||||||
map = require"love_src.src.new.world.race.components.map"
|
map = require"love_src.src.new.world.race.components.map"
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
local sfx = require"love_src.wrapper.lappy.new.source".obj
|
local sfx = require"love_src.wrapper.lappy.new.source".obj
|
||||||
local vm = require"lib.vornmath"
|
local vm = require"lib.vornmath"
|
||||||
|
local get_loop = require"love_src.src.system.animation".get_loop
|
||||||
|
|
||||||
local main_wrapper = require "love_src.wrapper.lappy.world"
|
local main_wrapper = require "love_src.wrapper.lappy.world"
|
||||||
---@class wrappers.Concord.world : lappy.world
|
---@class wrappers.Concord.world : lappy.world
|
||||||
@ -109,6 +110,8 @@ function world:setup()
|
|||||||
local countdown
|
local countdown
|
||||||
local checkpoints
|
local checkpoints
|
||||||
self.world_state = {}
|
self.world_state = {}
|
||||||
|
self.racers = {}
|
||||||
|
self.pov_index = 1
|
||||||
for _, d in pairs(self.entities_data) do
|
for _, d in pairs(self.entities_data) do
|
||||||
local e = {
|
local e = {
|
||||||
type = d.type,
|
type = d.type,
|
||||||
@ -128,6 +131,11 @@ function world:setup()
|
|||||||
countdown = e
|
countdown = e
|
||||||
elseif e.type == "checkpoints" then
|
elseif e.type == "checkpoints" then
|
||||||
checkpoints = e
|
checkpoints = e
|
||||||
|
elseif e.type == "racer" then
|
||||||
|
table.insert(self.racers, e)
|
||||||
|
if (e.components.actor.name == "player") then
|
||||||
|
e.components.racer.show_pov = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, e in ipairs(self.entities) do
|
for _, e in ipairs(self.entities) do
|
||||||
@ -168,6 +176,8 @@ local phases = {
|
|||||||
|
|
||||||
local phase = "intro"
|
local phase = "intro"
|
||||||
|
|
||||||
|
local x_is_down = false
|
||||||
|
|
||||||
function world:update(dt)
|
function world:update(dt)
|
||||||
for _, e in ipairs(self.entities) do
|
for _, e in ipairs(self.entities) do
|
||||||
for t, c in pairs(e.components) do
|
for t, c in pairs(e.components) do
|
||||||
@ -180,6 +190,15 @@ function world:update(dt)
|
|||||||
phases[phase].is_played = true
|
phases[phase].is_played = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (love.keyboard.isDown("x") and not x_is_down) then
|
||||||
|
self.racers[self.pov_index].components.racer.show_pov = false
|
||||||
|
self.pov_index = get_loop(self.pov_index + 1, #self.racers)
|
||||||
|
self.racers[self.pov_index].components.racer.show_pov = true
|
||||||
|
x_is_down = true
|
||||||
|
elseif (not love.keyboard.isDown("x") and x_is_down == true) then
|
||||||
|
x_is_down = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function world:draw()
|
function world:draw()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user