bevyjam/src/levels/level1.rs

59 lines
1.1 KiB
Rust
Raw Normal View History

2022-08-25 13:39:16 +00:00
// Switch tutorial
2022-08-23 10:02:58 +00:00
use crate::game::*;
2022-08-25 10:32:06 +00:00
use bevy::prelude::*;
2022-08-23 10:02:58 +00:00
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-25 07:30:47 +00:00
asset_server: &Res<AssetServer>,
2022-08-23 10:02:58 +00:00
) {
2022-08-25 13:39:16 +00:00
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
commands
.spawn_bundle(Text2dBundle {
text: Text::from_section(
"Press Tab to switch.",
TextStyle {
font,
font_size: 32.0,
color: Color::WHITE,
},
)
.with_alignment(TextAlignment::CENTER),
..Default::default()
})
.insert(Level);
2022-08-25 10:32:06 +00:00
spawn_platforms(
commands,
meshes,
materials,
[
(
Transform::from_xyz(0.0, -256.0, 0.0),
Vec2 { x: 800.0, y: 16.0 },
),
(
2022-08-25 13:39:16 +00:00
Transform::from_xyz(128.0, 256.0, 0.0),
Vec2 { x: 96.0, y: 16.0 },
2022-08-25 10:32:06 +00:00
),
],
);
2022-08-23 10:02:58 +00:00
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
[
2022-08-25 13:39:16 +00:00
(Transform::from_xyz(0., -192., 0.), Color::GREEN),
(Transform::from_xyz(-128., -192., 0.), Color::RED),
(Transform::from_xyz(128., 320., 0.), Color::BLUE),
2022-08-24 16:51:18 +00:00
],
2022-08-23 10:02:58 +00:00
);
}