fix movement
This commit is contained in:
parent
08521535fe
commit
6f1b083076
@ -13,7 +13,7 @@ extern "C" {
|
||||
void draw_quad(int x1, int y1, int x2, int y2,
|
||||
int x3, int y3, int x4, int y4);
|
||||
|
||||
void set_sphere(float x, float y, float angle);
|
||||
void set_sphere(float x, float y, float vx, float vy);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -140,12 +140,13 @@ local function force_workflow(
|
||||
weight_centrifugal
|
||||
)
|
||||
local val = add_desire(desire_forward, desire_steer, weight_forward, weight_steer)
|
||||
val = add_friction(val, grip, friction, weight_tire, weight_floor)
|
||||
val = add_drag(val, drag, streamline, weight_drag_boost)
|
||||
val = add_drag(val, drag_movement, streamline, weight_drag_halt)
|
||||
if (val[1] ~= 0 and val[2] ~= 0) then
|
||||
val = add_friction(val, grip, friction, weight_tire, weight_floor)
|
||||
val = add_drag(val, drag, streamline, weight_drag_boost)
|
||||
val = add_drag(val, drag_movement, streamline, weight_drag_halt)
|
||||
val = add_centrifugal(val, mass, inertia_force, weight_centrifugal)
|
||||
end
|
||||
val = add_inertia(val, inertia_force, weight_inertia)
|
||||
val = add_centrifugal(val, mass, inertia_force, weight_centrifugal)
|
||||
|
||||
return val
|
||||
end
|
||||
|
||||
|
||||
@ -34,12 +34,12 @@ function wrapper:load(_args)
|
||||
velocity = {0.0, 0.0},
|
||||
max_speed = 10.0,
|
||||
|
||||
accel = 10.0,
|
||||
brake = 10.0,
|
||||
grip = 10.0,
|
||||
steer = 10.0,
|
||||
accel = 2.0,
|
||||
brake = 1.0,
|
||||
grip = 1.0,
|
||||
steer = 1.0,
|
||||
inertia = {0.0, 0.0},
|
||||
mass = 10.0,
|
||||
mass = 1.0,
|
||||
streamline = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +154,8 @@ local magic_w = {
|
||||
steer = 1.0,
|
||||
drag_boost = 1.0,
|
||||
drag_halt = 1.5,
|
||||
inertia = 1.0,
|
||||
centrifugal = 1.0,
|
||||
inertia = 0.001,
|
||||
centrifugal = 0.001,
|
||||
drag_movement = 1.0
|
||||
-- magic_slowdown = 10.0,
|
||||
-- magic_boost = 10000.0,
|
||||
@ -176,9 +176,9 @@ local function handle_input(accel, brake, steer)
|
||||
desire_forward = - brake
|
||||
end
|
||||
if (left) then
|
||||
desire_steer = - steer
|
||||
elseif (right) then
|
||||
desire_steer = steer
|
||||
elseif (right) then
|
||||
desire_steer = - steer
|
||||
end
|
||||
return desire_forward, desire_steer
|
||||
end
|
||||
@ -218,6 +218,8 @@ function system:update(dt)
|
||||
local a = force * dt / mass
|
||||
|
||||
e[race.dict.velocity].data = e[race.dict.velocity].data + a
|
||||
e[race.dict.velocity].data[1] = vm.clamp(e[race.dict.velocity].data[1], -max_speed, max_speed)
|
||||
e["race.pos"].data = e["race.pos"].data + e[race.dict.velocity].data
|
||||
|
||||
-- local new_velocity = racing_phy.accelerate(dt, 1, velocity, max_speed, f_forward*dt/mass, 0)
|
||||
|
||||
|
||||
@ -267,7 +267,7 @@ function love.run()
|
||||
local time = love.timer.getTime()
|
||||
--update(time)
|
||||
test.update(time)
|
||||
local dt = last_time - time
|
||||
local dt = time - last_time
|
||||
last_time = time
|
||||
love_update(dt)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user