local function accelerate(dt, gas_input, speed, max_speed, accel, min_speed)
  if (min_speed == nil) then
    min_speed = 0
  end
  local new_speed = speed + accel * dt * gas_input
  if (new_speed >= max_speed) then
    new_speed = max_speed
  elseif (new_speed <= min_speed) then
    new_speed = min_speed
  elseif(new_speed <= -max_speed) then
    new_speed = -max_speed
  end
  return new_speed
end

local function drift(dt, pos_x, speed, max_speed, curve, centrifugal)
  local speed_percent = (speed/max_speed)
  local dx = dt * 2 * speed_percent -- at top speed, should be able to cross from left to right (-1 to 1) in 1 second
  return pos_x - (dx * speed_percent * curve * centrifugal);
end

return {
  accelerate = accelerate,
  drift = drift
}
