Spawn areas with correct size, remove printlns, and reformat.
This commit is contained in:
parent
f16333d258
commit
02eff61016
20
src/map.rs
20
src/map.rs
|
@ -210,12 +210,14 @@ fn spawn_colliders(
|
||||||
) {
|
) {
|
||||||
for (map_entity, map, spawn_colliders, spawn_collider_per_tile) in maps.iter() {
|
for (map_entity, map, spawn_colliders, spawn_collider_per_tile) in maps.iter() {
|
||||||
if **spawn_colliders {
|
if **spawn_colliders {
|
||||||
commands.entity(map_entity).remove::<SpawnColliders>();
|
commands
|
||||||
commands.entity(map_entity).remove::<SpawnColliderPerTile>();
|
.entity(map_entity)
|
||||||
commands.entity(map_entity).insert_bundle(RigidBodyBundle {
|
.remove::<SpawnColliders>()
|
||||||
body_type: RigidBodyType::Static,
|
.remove::<SpawnColliderPerTile>()
|
||||||
..Default::default()
|
.insert_bundle(RigidBodyBundle {
|
||||||
});
|
body_type: RigidBodyType::Static,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
if **spawn_collider_per_tile {
|
if **spawn_collider_per_tile {
|
||||||
for y in 0..map.height {
|
for y in 0..map.height {
|
||||||
for x in 0..map.width {
|
for x in 0..map.width {
|
||||||
|
@ -335,10 +337,8 @@ fn spawn_colliders(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for room in &map.rooms {
|
for room in &map.rooms {
|
||||||
let shape = ColliderShape::cuboid(
|
let shape =
|
||||||
(room.width() / 2) as f32 + 0.5,
|
ColliderShape::cuboid((room.width() / 2) as f32, (room.height() / 2) as f32);
|
||||||
(room.height() / 2) as f32 + 0.5,
|
|
||||||
);
|
|
||||||
let position = Vec2::new(room.center().x() + 0.5, room.center().y() + 0.5).into();
|
let position = Vec2::new(room.center().x() + 0.5, room.center().y() + 0.5).into();
|
||||||
let id = commands
|
let id = commands
|
||||||
.spawn_bundle(ColliderBundle {
|
.spawn_bundle(ColliderBundle {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user