Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinmorrow committed Jul 15, 2023
1 parent a052d45 commit 9c26b0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ pub fn keep_player_in_view(

const PADDING: f32 = 256.0;

trace!("player_x: {}, camera_x: {}", player_x, camera_x);

let distance = camera_x - player_x;
if distance.abs() > window.width() / 2.0 - PADDING {
debug!("Moving camera to catch up with player");

let new_x = player_x + (window.width() / 2.0 - PADDING) * distance.signum();
trace!("new_x: {}", new_x);

// move the camera to catch up with the player
camera.translation.x = player_x + (window.width() / 2.0 - PADDING) * distance.signum();
camera.translation.x = new_x;
}
}
2 changes: 2 additions & 0 deletions src/level/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ impl core::fmt::Debug for BlockBundle {

impl BlockBundle {
pub fn new(translation: Vec3) -> Self {
trace!("Creating block bundle (translation: {:?})", translation);

Self {
sprite_bundle: SpriteBundle {
transform: Transform {
Expand Down
7 changes: 5 additions & 2 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ pub fn r#move(
) {
let action_state = action_state_query.single();
let Ok(mut player) = player_query.get_single_mut() else { return; };
let actions = action_state.get_pressed();

debug!("Moving player.");
if actions.len() > 0 {
debug!("Moving player.");
}

for action in action_state.get_pressed() {
for action in actions {
trace!("Action: {:#?}", action);
match action {
Action::Left => player.x = -300.0,
Expand Down

0 comments on commit 9c26b0e

Please sign in to comment.