Cleanup
This commit is contained in:
+5
-2
@@ -1,6 +1,9 @@
|
|||||||
use avian2d::{math::*, prelude::*};
|
use avian2d::{math::*, prelude::*};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
|
||||||
|
const PLAYER_SPEED: f32 = 300.0;
|
||||||
|
|
||||||
pub struct CharacterControllerPlugin;
|
pub struct CharacterControllerPlugin;
|
||||||
|
|
||||||
impl Plugin for CharacterControllerPlugin {
|
impl Plugin for CharacterControllerPlugin {
|
||||||
@@ -48,8 +51,8 @@ impl CharacterControllerBundle {
|
|||||||
character_controller: CharacterController,
|
character_controller: CharacterController,
|
||||||
body: RigidBody::Dynamic,
|
body: RigidBody::Dynamic,
|
||||||
collider,
|
collider,
|
||||||
speed: MaxSpeed(300.),
|
speed: MaxSpeed(PLAYER_SPEED),
|
||||||
acceleration: MaxAcceleration(50000.),
|
acceleration: MaxAcceleration(5000.),
|
||||||
enabled: InputEnabled(true),
|
enabled: InputEnabled(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -1,15 +1,16 @@
|
|||||||
use crate::avian::{CharacterControllerBundle, CharacterControllerPlugin, InputEnabled};
|
use crate::avian::{CharacterControllerBundle, CharacterControllerPlugin};
|
||||||
use crate::world::{Player, MainCamera, WorldPlugin};
|
use crate::world::{MainCamera, Player, WorldPlugin};
|
||||||
use avian2d::{
|
|
||||||
PhysicsPlugins,
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use avian2d::parry::simba::simd::SimdComplexField;
|
use avian2d::parry::simba::simd::SimdComplexField;
|
||||||
use bevy::{camera::ScalingMode, color::palettes::css::GREEN, prelude::*};
|
use avian2d::{
|
||||||
|
prelude::*,
|
||||||
|
PhysicsPlugins,
|
||||||
|
};
|
||||||
use bevy::tasks::futures_lite::StreamExt;
|
use bevy::tasks::futures_lite::StreamExt;
|
||||||
|
use bevy::{camera::ScalingMode, color::palettes::css::GREEN, prelude::*};
|
||||||
pub mod avian;
|
pub mod avian;
|
||||||
pub mod world;
|
pub mod world;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
|
|||||||
+4
-8
@@ -3,7 +3,6 @@ use avian2d::prelude::{Collider, CollidingEntities, CollisionEventsEnabled, Coll
|
|||||||
use bevy::camera::Viewport;
|
use bevy::camera::Viewport;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::window::PrimaryWindow;
|
use bevy::window::PrimaryWindow;
|
||||||
// use crate::{room_center, CurrentRoom, Direction, Door, FadeOverlay, GameState, MainCamera, Player, RoomTransition, TransitionPhase, DOOR_DEPTH, DOOR_WIDTH, FADE_DURATION, HALF_H, HALF_W, ROOM_HEIGHT, ROOM_WIDTH, SPAWN_DISTANCE, TARGET_ASPECT, WALL_THICKNESS};
|
|
||||||
use crate::avian::InputEnabled;
|
use crate::avian::InputEnabled;
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ const DOOR_WIDTH: f32 = 120.0;
|
|||||||
const DOOR_DEPTH: f32 = 40.0;
|
const DOOR_DEPTH: f32 = 40.0;
|
||||||
const SPAWN_DISTANCE: f32 = 80.0;
|
const SPAWN_DISTANCE: f32 = 80.0;
|
||||||
|
|
||||||
const PLAYER_SPEED: f32 = 300.0;
|
|
||||||
const FADE_DURATION: f32 = 0.35;
|
const FADE_DURATION: f32 = 0.35;
|
||||||
|
|
||||||
|
|
||||||
@@ -46,9 +44,9 @@ impl Plugin for WorldPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
spawn_room(&mut commands, IVec2::new(0, 0), Color::srgb(0.15, 0.15, 0.25), vec![Direction::North, Direction::East], &asset_server);
|
spawn_room(&mut commands, IVec2::new(0, 0), vec![Direction::North, Direction::East], &asset_server);
|
||||||
spawn_room(&mut commands, IVec2::new(1, 0), Color::srgb(0.25, 0.15, 0.15), vec![Direction::West], &asset_server);
|
spawn_room(&mut commands, IVec2::new(1, 0), vec![Direction::West], &asset_server);
|
||||||
spawn_room(&mut commands, IVec2::new(0, 1), Color::srgb(0.15, 0.25, 0.15), vec![Direction::South], &asset_server);
|
spawn_room(&mut commands, IVec2::new(0, 1), vec![Direction::South], &asset_server);
|
||||||
|
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
@@ -114,7 +112,7 @@ enum Direction {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn spawn_room(commands: &mut Commands, room: IVec2, color: Color, door_directions: Vec<Direction>, asset_server: &Res<AssetServer>) {
|
fn spawn_room(commands: &mut Commands, room: IVec2, door_directions: Vec<Direction>, asset_server: &Res<AssetServer>) {
|
||||||
let center = room_center(room);
|
let center = room_center(room);
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
@@ -238,7 +236,6 @@ fn door_detection(
|
|||||||
doors: Query<&Door>,
|
doors: Query<&Door>,
|
||||||
mut started: MessageReader<CollisionStart>,
|
mut started: MessageReader<CollisionStart>,
|
||||||
) {
|
) {
|
||||||
let player_pos = player.1.translation.truncate();
|
|
||||||
|
|
||||||
for event in started.read() {
|
for event in started.read() {
|
||||||
println!("CollisionStart: {event:?}");
|
println!("CollisionStart: {event:?}");
|
||||||
@@ -272,7 +269,6 @@ fn door_target_room(door: &Door) -> IVec2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn door_target_position(door: &Door) -> Vec2 {
|
fn door_target_position(door: &Door) -> Vec2 {
|
||||||
let target_room_center = room_center(door_target_room(door));
|
|
||||||
match door.travel_direction {
|
match door.travel_direction {
|
||||||
Direction::North => Vec2::new(0.0, -HALF_H + WALL_THICKNESS + DOOR_DEPTH + SPAWN_DISTANCE),
|
Direction::North => Vec2::new(0.0, -HALF_H + WALL_THICKNESS + DOOR_DEPTH + SPAWN_DISTANCE),
|
||||||
Direction::East => Vec2::new(-HALF_W + WALL_THICKNESS + DOOR_DEPTH + SPAWN_DISTANCE, 0.0),
|
Direction::East => Vec2::new(-HALF_W + WALL_THICKNESS + DOOR_DEPTH + SPAWN_DISTANCE, 0.0),
|
||||||
|
|||||||
Reference in New Issue
Block a user