add initial boost
This commit is contained in:
parent
5c2aa31153
commit
6a300c5b8f
@ -22,7 +22,7 @@ end
|
||||
function world:load_world_state(world_state)
|
||||
self.e.components.animation.data.triggers_fn[4] = function ()
|
||||
if (not self.disappear) then
|
||||
world_state.components.world_state.data.state = "START"
|
||||
world_state.data.state = "start"
|
||||
self.e.components.animation.data.anim_direction = 0
|
||||
self.disappear = 2
|
||||
end
|
||||
@ -48,7 +48,8 @@ function world:ui_draw()
|
||||
self.data.label_color
|
||||
)
|
||||
else
|
||||
uir.draw_text("",
|
||||
self.data.label = ""
|
||||
uir.draw_text(self.data.label,
|
||||
self.data.pos[1], self.data.pos[2],
|
||||
self.data.label_color
|
||||
)
|
||||
|
||||
@ -49,6 +49,11 @@ function world:load(entity, data)
|
||||
self.e = entity
|
||||
self.data = data or default
|
||||
self.map = {}
|
||||
|
||||
self.countdown = {}
|
||||
self.world_state = {}
|
||||
|
||||
self.late_timer = 0
|
||||
end
|
||||
|
||||
function get(s)
|
||||
@ -108,6 +113,11 @@ function world:update_race(dt)
|
||||
|
||||
local desire_forward, desire_steer = self.e.components.actor.data.forward, self.e.components.actor.data.steer
|
||||
|
||||
if (self.world_state.data.state == "start" and self.countdown.data.label == "go") then
|
||||
self.late_timer = self.late_timer + dt
|
||||
self.initial_boost = false
|
||||
end
|
||||
|
||||
local force = racing_force(
|
||||
desire_forward, desire_steer,
|
||||
grip, friction,
|
||||
@ -122,14 +132,22 @@ function world:update_race(dt)
|
||||
local f_v = forward_velocity(dt, force, mass, velocity, max_speed, min_speed, magic_w.dampening)
|
||||
local o, o_v = orientation_velocity(dt, force, mass, self.data.orientation_speed, self.data.orientation, self.data.max_orientation_speed, self.data.min_orientation_speed)
|
||||
|
||||
self.data.velocity[1] = f_v
|
||||
-- self.data.orientation_speed = o_v
|
||||
self.data.orientation = o
|
||||
-- if (self.data.velocity[1] ~= 0) then
|
||||
self.data.pos = self.data.pos + o * f_v
|
||||
-- end
|
||||
if (self.world_state.data.state == "count down") then
|
||||
|
||||
self.data.inertia = force
|
||||
else
|
||||
if (self.late_timer < 1 and not self.initial_boost) then
|
||||
f_v = f_v + 0.1
|
||||
self.initial_boost = true
|
||||
end
|
||||
self.data.velocity[1] = f_v
|
||||
-- self.data.orientation_speed = o_v
|
||||
self.data.orientation = o
|
||||
-- if (self.data.velocity[1] ~= 0) then
|
||||
self.data.pos = self.data.pos + o * f_v
|
||||
-- end
|
||||
|
||||
self.data.inertia = force
|
||||
end
|
||||
end
|
||||
|
||||
function world:update(dt)
|
||||
|
||||
@ -106,6 +106,7 @@ end
|
||||
|
||||
function world:setup()
|
||||
local map
|
||||
local countdown
|
||||
self.world_state = {}
|
||||
for _, d in pairs(self.entities_data) do
|
||||
local e = {
|
||||
@ -122,17 +123,17 @@ function world:setup()
|
||||
map = e
|
||||
elseif e.type == "world_state" then
|
||||
self.world_state = e
|
||||
elseif e.type == "countdown" then
|
||||
countdown = e
|
||||
end
|
||||
end
|
||||
for _, e in ipairs(self.entities) do
|
||||
if (e.type == "racer") then
|
||||
for t, c in pairs(e.components) do
|
||||
if (c.name == "racer") then
|
||||
c.map = map.components.map
|
||||
end
|
||||
end
|
||||
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
|
||||
elseif (e.type == "countdown") then
|
||||
e.components.countdown:load_world_state(self.world_state)
|
||||
e.components.countdown:load_world_state(self.world_state.components.world_state)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user