Beginning work with collision detection
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 31s
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 31s
I'm going to grab the Rapier physics library so that I don't have to do my own collision detection mechanism. The last time I did this, I simplified everything into circles. This time I'd like to have convex hulls, particularly for the player ship. Also the last time, I ended up rolling my own quadtree impl. I'm not particularly interested in doing that again, and I'd like to learn more of the broader Bevy ecosystem.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use bevy_rapier2d::prelude::Collider;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -107,8 +108,16 @@ pub fn spawn_asteroid(
|
||||
AsteroidSize::Medium => game_assets.asteroid_medium(),
|
||||
AsteroidSize::Large => game_assets.asteroid_large(),
|
||||
};
|
||||
|
||||
let collider_radius = match spawn.size {
|
||||
AsteroidSize::Small => 10.0,
|
||||
AsteroidSize::Medium => 20.0,
|
||||
AsteroidSize::Large => 40.0,
|
||||
};
|
||||
|
||||
commands.spawn((
|
||||
Asteroid(AsteroidSize::Small),
|
||||
Collider::ball(collider_radius),
|
||||
Position(spawn.pos),
|
||||
Velocity(spawn.vel),
|
||||
Rotation(0.0),
|
||||
|
||||
Reference in New Issue
Block a user