feat: left/right world boundaries
parent
a8a0afcbeb
commit
ff2ab7c3a2
21
src/game.rs
21
src/game.rs
|
|
@ -29,7 +29,6 @@ pub fn init() {
|
|||
.add_plugin(Terrain2DPlugin)
|
||||
.add_plugin(PlayerPlugin)
|
||||
.add_startup_system(setup_debug_terrain)
|
||||
// .add_startup_system(setup_debug_camera)
|
||||
.add_system(debug_controls)
|
||||
.run();
|
||||
}
|
||||
|
|
@ -45,17 +44,7 @@ fn debug_controls(
|
|||
}
|
||||
}
|
||||
|
||||
fn setup_debug_camera(mut commands: Commands) {
|
||||
commands
|
||||
.spawn(TransformBundle::default())
|
||||
.insert(Name::new("Debug Camera"))
|
||||
.insert(CameraFollow {
|
||||
movement: camera::FollowMovement::Smooth(10.0),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
||||
fn setup_debug_terrain(mut terrain: ResMut<Terrain2D>) {
|
||||
fn setup_debug_terrain(mut commands: Commands, mut terrain: ResMut<Terrain2D>) {
|
||||
let terrain_gen = TerrainGen2D::new(432678);
|
||||
for y in 0..(WORLD_WIDTH / Chunk2D::SIZE_Y as i32) {
|
||||
for x in 0..(WORLD_WIDTH / Chunk2D::SIZE_X as i32) {
|
||||
|
|
@ -63,4 +52,12 @@ fn setup_debug_terrain(mut terrain: ResMut<Terrain2D>) {
|
|||
terrain.add_chunk(position, terrain_gen.gen_chunk(&position));
|
||||
}
|
||||
}
|
||||
|
||||
commands.spawn(Name::new("Left wall"))
|
||||
.insert(Collider::halfspace(Vec2::X).unwrap())
|
||||
.insert(TransformBundle::from_transform(Transform::from_translation(Vec3::new(0.0, 0.0, 0.0))));
|
||||
|
||||
commands.spawn(Name::new("Right wall"))
|
||||
.insert(Collider::halfspace(Vec2::NEG_X).unwrap())
|
||||
.insert(TransformBundle::from_transform(Transform::from_translation(Vec3::new(WORLD_WIDTH as f32, 0.0, 0.0))));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue