Spawn areas with correct size, remove printlns, and reformat.

This commit is contained in:
Nolan Darilek 2021-09-14 10:36:16 -05:00
parent f16333d258
commit 02eff61016

View File

@ -210,12 +210,14 @@ fn spawn_colliders(
) {
for (map_entity, map, spawn_colliders, spawn_collider_per_tile) in maps.iter() {
if **spawn_colliders {
commands.entity(map_entity).remove::<SpawnColliders>();
commands.entity(map_entity).remove::<SpawnColliderPerTile>();
commands.entity(map_entity).insert_bundle(RigidBodyBundle {
body_type: RigidBodyType::Static,
..Default::default()
});
commands
.entity(map_entity)
.remove::<SpawnColliders>()
.remove::<SpawnColliderPerTile>()
.insert_bundle(RigidBodyBundle {
body_type: RigidBodyType::Static,
..Default::default()
});
if **spawn_collider_per_tile {
for y in 0..map.height {
for x in 0..map.width {
@ -335,10 +337,8 @@ fn spawn_colliders(
}
}
for room in &map.rooms {
let shape = ColliderShape::cuboid(
(room.width() / 2) as f32 + 0.5,
(room.height() / 2) as f32 + 0.5,
);
let shape =
ColliderShape::cuboid((room.width() / 2) as f32, (room.height() / 2) as f32);
let position = Vec2::new(room.center().x() + 0.5, room.center().y() + 0.5).into();
let id = commands
.spawn_bundle(ColliderBundle {