ZKF3CN33IANIGHYTNQDTWDIG7ZG6JMRQXTGRHNARW2LZ3U6SXUCAC
G3FE5YP2OBTWE563KVAJTSUGIYNF3NDOVZSOP2DART725GPZRC3QC
WQS2WD437EWG2CKPOY5TDWPEBE3US7LGHVAH2HVYQ7RW2L6FHJ5AC
VICUJP7SGKKCO2ZWO5ACSO3OS4HV4JTXTHQHYSFOADANGUJ5ZDDAC
ELGDDPUWFOH6ELJVCFVNUQJQRB44G66BJXVQWQGQHNUWYA3XQJVQC
EV477LPQ57FEHMFO6E3LL5MFWZC6NTGER42SKP5CJN73SWXGB5AQC
KYEVTQT5IWDHVCMV2TORNQPODLJBKD3HLS4EIXR5HOL5DZI3UVKQC
J32UZAU7V6XDZUSDHMLVA474JC4S4AHMLZZN55XC74YMXW4ZMFKQC
5Y32O2B2GTH2UHFA3NO4ZY673XNHT3W4DQADFMK4LMKLSXMZKHGQC
7FTW5AQKOO4W5AIHYZSAKLQR6LGVTXH7SKMSTA4ER4C4HP54VE4QC
MKB2A5XCWBZO2E6QFE6PD36LF3IGMJCGJB5TGMRAPSKCKHS75ISAC
EQ6ZV6AZEAW6XVZFIZCMKFFE6EAL2I2XTLDTN7BUC53T5H7FS5FQC
DBHCCY3W2DG4WYMXBZ2UCNYVGZ5PS5UUUNWCXVYJ4TMXQDIZT6GAC
7SXAXY6J4QHPDUUHCKZDEZOZ2IUMSBWODICOMIZH2KA2BGV3F54QC
/// alpha is clamped to [0.0, 1.0]
fn lerp_mix(a: Color, b: Color, alpha: f32) -> Color {
use palette::{
blend::{BlendWith, PreAlpha},
LinSrgb, Srgba,
};
type PreRgba = PreAlpha<LinSrgb<f32>>;
let alpha = alpha.clamp(0.0, 1.0);
let a_rgb = Srgba::from(a.as_rgba_f32()).into_linear();
let b_rgb = Srgba::from(b.as_rgba_f32()).into_linear();
let mixed = a_rgb.blend_with(b_rgb, |a: PreRgba, b: PreRgba| {
// lerp em colors togethter
PreAlpha {
color: LinSrgb::new(
a.red + (b.red - a.red) * alpha,
a.green + (b.green - a.green) * alpha,
a.blue + (b.blue - a.blue) * alpha,
),
alpha: a.alpha + (b.alpha - a.alpha) * alpha,
}
});
Color::rgba(mixed.red, mixed.green, mixed.blue, mixed.alpha)
}
let speed = movable.velocity.length();
if let Some(vnorm) = movable.velocity.try_normalize() {
// info!(?movable);
if movable.velocity.length() > MIN_SPEED {
let vnorm = movable.velocity.normalize();
// Friction = mu * N where N is the normal force
// we assume the only normal force is gravity.
// so friction in our system is
// mu * mass * gravity
let mass = movable.mass;
let friction_magnitude = FAKE_MU * mass.max(1.0).recip();
movable.velocity -= vnorm * friction_magnitude;
} else {
let vnorm = movable.velocity.normalize_or_zero();
let friction_magnitude =
if speed <= MIN_SPEED { MU_STATIC } else { MU } * mass.max(1.0) * GRAVITY;
movable.acceleration += -vnorm * friction_magnitude;
let friction_magnitude = FAKE_MU_STATIC * mass.max(1.0).recip();
movable.velocity -= vnorm * friction_magnitude;
}
pub(crate) mod utils {
use bevy::prelude::Color;
/// alpha is clamped to [0.0, 1.0]
pub fn lerp_mix(a: Color, b: Color, alpha: f32) -> Color {
use palette::{
blend::{BlendWith, PreAlpha},
LinSrgb, Srgba,
};
type PreRgba = PreAlpha<LinSrgb<f32>>;
let alpha = alpha.clamp(0.0, 1.0);
let a_rgb = Srgba::from(a.as_rgba_f32()).into_linear();
let b_rgb = Srgba::from(b.as_rgba_f32()).into_linear();
let mixed = a_rgb.blend_with(b_rgb, |a: PreRgba, b: PreRgba| {
// lerp em colors togethter
PreAlpha {
color: LinSrgb::new(
a.red + (b.red - a.red) * alpha,
a.green + (b.green - a.green) * alpha,
a.blue + (b.blue - a.blue) * alpha,
),
alpha: a.alpha + (b.alpha - a.alpha) * alpha,
}
});
Color::rgba(mixed.red, mixed.green, mixed.blue, mixed.alpha)
}
(
meta_format_version: "1.0",
asset: Load(
loader: "bevy_ecs_ldtk::assets::ldtk_project::LdtkProjectLoader",
settings: (),
),
)
(
meta_format_version: "1.0",
asset: Load(
loader: "bevy_render::render_resource::shader::ShaderLoader",
settings: (),
),
)
(
meta_format_version: "1.0",
asset: Load(
loader: "bevy_render::texture::image_loader::ImageLoader",
settings: (
format: FromExtension,
is_srgb: true,
sampler: Default,
asset_usage: ("MAIN_WORLD | RENDER_WORLD"),
),
),
)
(
meta_format_version: "1.0",
asset: Ignore,
)
(
meta_format_version: "1.0",
asset: Load(
loader: "bevy_render::texture::image_loader::ImageLoader",
settings: (
format: FromExtension,
is_srgb: true,
sampler: Default,
asset_usage: ("MAIN_WORLD | RENDER_WORLD"),
),
),
)
(
meta_format_version: "1.0",
asset: Ignore,
)
(
meta_format_version: "1.0",
asset: Load(
loader: "bevy_render::texture::image_loader::ImageLoader",
settings: (
format: FromExtension,
is_srgb: true,
sampler: Default,
asset_usage: ("MAIN_WORLD | RENDER_WORLD"),
),
),
)
(
meta_format_version: "1.0",
asset: Ignore,
)