-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathmain.rs
52 lines (48 loc) · 2.15 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This example shows off a more in-depth implementation of a game with `bevy_ecs_ldtk`.
// Please run with `--release`.
use bevy::prelude::*;
use bevy_ecs_ldtk::prelude::*;
use bevy_rapier2d::prelude::*;
mod components;
mod systems;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugin(LdtkPlugin)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
// Required to prevent race conditions between bevy_ecs_ldtk's and bevy_rapier's systems
.configure_set(LdtkSystemSet::ProcessApi.before(PhysicsSet::SyncBackend))
.insert_resource(RapierConfiguration {
gravity: Vec2::new(0.0, -2000.0),
..Default::default()
})
.insert_resource(LevelSelection::Uid(0))
.insert_resource(LdtkSettings {
level_spawn_behavior: LevelSpawnBehavior::UseWorldTranslation {
load_level_neighbors: true,
},
set_clear_color: SetClearColor::FromLevelBackground,
..Default::default()
})
.add_startup_system(systems::setup)
.add_system(systems::spawn_wall_collision)
.add_system(systems::movement)
.add_system(systems::detect_climb_range)
.add_system(systems::ignore_gravity_if_climbing)
.add_system(systems::patrol)
.add_system(systems::camera_fit_inside_current_level)
.add_system(systems::update_level_selection)
.add_system(systems::dbg_player_items)
.add_system(systems::spawn_ground_sensor)
.add_system(systems::ground_detection)
.add_system(systems::update_on_ground)
.add_system(systems::restart_level)
.register_ldtk_int_cell::<components::WallBundle>(1)
.register_ldtk_int_cell::<components::LadderBundle>(2)
.register_ldtk_int_cell::<components::WallBundle>(3)
.register_ldtk_entity::<components::PlayerBundle>("Player")
.register_ldtk_entity::<components::MobBundle>("Mob")
.register_ldtk_entity::<components::ChestBundle>("Chest")
.register_ldtk_entity::<components::PumpkinsBundle>("Pumpkins")
.run();
}