bevyjam/src/levels/level0.rs

40 lines
922 B
Rust
Raw Normal View History

2022-08-23 10:02:58 +00:00
use crate::game::*;
2022-08-24 10:21:08 +00:00
use bevy::prelude::{shape::Quad, *};
2022-08-23 10:02:58 +00:00
use bevy_rapier2d::prelude::*;
pub fn setup(
commands: &mut Commands,
2022-08-24 10:21:08 +00:00
meshes: &mut ResMut<Assets<Mesh>>,
2022-08-23 10:02:58 +00:00
character_meshes: &Res<CharacterMeshes>,
materials: &mut ResMut<Assets<ColorMaterial>>,
2022-08-23 15:02:13 +00:00
audio: &Res<crossbeam_channel::Sender<AudioMsg>>,
2022-08-23 10:02:58 +00:00
) {
commands
2022-08-24 10:21:08 +00:00
.spawn_bundle(ColorMesh2dBundle {
mesh: meshes
.add(Mesh::from(Quad {
size: Vec2 { x: 800.0, y: 16.0 },
flip: false,
}))
.into(),
material: materials.add(ColorMaterial::from(Color::GRAY)),
transform: Transform::from_xyz(0.0, -256.0, 0.0),
..default()
})
.insert(Collider::cuboid(400., 8.))
2022-08-23 10:02:58 +00:00
.insert(Level);
2022-08-24 16:51:18 +00:00
spawn_characters(
2022-08-23 10:02:58 +00:00
commands,
character_meshes,
materials,
2022-08-23 15:02:13 +00:00
audio,
2022-08-24 16:51:18 +00:00
[
(Transform::from_xyz(-128., -64., 0.), Color::RED),
(Transform::from_xyz(0., -64., 0.), Color::GREEN),
(Transform::from_xyz(128., -64., 0.), Color::BLUE),
],
2022-08-23 10:02:58 +00:00
);
}