camera controller!!!
This commit is contained in:
parent
b51241b1fc
commit
9e70d24779
3 changed files with 38 additions and 11 deletions
|
@ -2,15 +2,16 @@ info section
|
||||||
block-size = 60
|
block-size = 60
|
||||||
.P = [player]
|
.P = [player]
|
||||||
.T = Blockgrau.png
|
.T = Blockgrau.png
|
||||||
.E = erdblock.png
|
.E = erdblock_lower.png
|
||||||
.G = grasblock_lower.png
|
.G = grasblock_lower.png
|
||||||
._ = _grasblock_upper.png
|
._ = _grasblock_upper.png
|
||||||
|
., = _erdblock_upper.png
|
||||||
world section
|
world section
|
||||||
|
|
||||||
TT
|
T P
|
||||||
TTT P _______ ______ ___
|
TT ,,,_______,,,______,___
|
||||||
TTTTTTTTTEEEGGGGGGGETEGGGGGGEGGGE
|
TTTTTTTTEEEGGGGGGGEEEGGGGGGEGGGE
|
||||||
TTTTTTTTTTEEEEEEEEEEEEEEEEEEEEEEE
|
TTTTTTTTTEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
TTTTTTTEEEEEEEEEEEEEEEEEEEEEEEEEE
|
TTTTTTEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
|
|
|
@ -53,15 +53,19 @@ fn move_player(
|
||||||
kb_input: Res<ButtonInput<KeyCode>>,
|
kb_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut query: Query<(
|
mut query: Query<(
|
||||||
&mut Velocity,
|
&mut Velocity,
|
||||||
|
&Transform,
|
||||||
&mut Player,
|
&mut Player,
|
||||||
&mut KinematicCharacterController,
|
&mut KinematicCharacterController,
|
||||||
)>,
|
)>,
|
||||||
|
mut camera_query: Query<&mut Transform, (With<Camera2d>, Without<Player>)>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
) {
|
) {
|
||||||
let (mut vel, mut player, mut controller) = query.single_mut();
|
let (mut vel, p_transform, mut player, mut controller) = query.single_mut();
|
||||||
|
let (mut cam_transform) = camera_query.single_mut();
|
||||||
if player.move_cooldown.tick(time.delta()).finished() {
|
if player.move_cooldown.tick(time.delta()).finished() {
|
||||||
let mut moved = false;
|
let mut moved = false;
|
||||||
let mut mv = 0;
|
let mut mv = 0;
|
||||||
|
let mut jump = false;
|
||||||
|
|
||||||
if kb_input.pressed(KeyCode::KeyA) {
|
if kb_input.pressed(KeyCode::KeyA) {
|
||||||
moved = true;
|
moved = true;
|
||||||
|
@ -72,6 +76,10 @@ fn move_player(
|
||||||
mv += 1;
|
mv += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let orig = cam_transform.translation;
|
||||||
|
println!("{orig:?}");
|
||||||
|
cam_transform.translation -= ((orig - p_transform.translation.xy().extend(0.0)) / 30.0);
|
||||||
|
|
||||||
if moved {
|
if moved {
|
||||||
dbg!(mv);
|
dbg!(mv);
|
||||||
controller.translation = Some(Vec2::new(mv as f32 * 6., 0.));
|
controller.translation = Some(Vec2::new(mv as f32 * 6., 0.));
|
||||||
|
@ -139,6 +147,24 @@ fn add_player(
|
||||||
Velocity::default(),
|
Velocity::default(),
|
||||||
))
|
))
|
||||||
.insert(KinematicCharacterController {
|
.insert(KinematicCharacterController {
|
||||||
|
//translation: todo!(),
|
||||||
|
//custom_shape: todo!(),
|
||||||
|
//custom_mass: todo!(),
|
||||||
|
//up: todo!(),
|
||||||
|
//offset: todo!(),
|
||||||
|
//slide: todo!(),
|
||||||
|
//autostep: Some(CharacterAutostep {
|
||||||
|
// max_height: CharacterLength::Relative(0.1),
|
||||||
|
// min_width: CharacterLength::Absolute(1.0),
|
||||||
|
// include_dynamic_bodies: false,
|
||||||
|
//}),
|
||||||
|
//max_slope_climb_angle: todo!(),
|
||||||
|
//min_slope_slide_angle: todo!(),
|
||||||
|
//apply_impulse_to_dynamic_bodies: todo!(),
|
||||||
|
//snap_to_ground: Some(CharacterLength::Absolute(1.0)),
|
||||||
|
//filter_flags: todo!(),
|
||||||
|
//filter_groups: todo!(),
|
||||||
|
//normal_nudge_factor: todo!(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ pub struct PlayerCoords {
|
||||||
|
|
||||||
impl PlayerCoords {
|
impl PlayerCoords {
|
||||||
pub fn get_collider(&self) -> Collider {
|
pub fn get_collider(&self) -> Collider {
|
||||||
let size = self.block_size * PLAYER_SIZE_FRACTION * 0.5;
|
let size = 0.5;
|
||||||
|
|
||||||
Collider::cuboid(size, size)
|
Collider::round_cuboid(size, size, 1.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue