diff --git a/game/dist/project-constants.json b/game/dist/project-constants.json index 537edb67..46f8c02e 100644 --- a/game/dist/project-constants.json +++ b/game/dist/project-constants.json @@ -18,8 +18,8 @@ } }, "player": { - "max_velocity": 30, - "acceleration": 20, + "max_velocity": 3, + "acceleration": 2, "deceleration": 1, "start_size": 0.8 } diff --git a/game/game_logic/src/scenes/player_interaction.rs b/game/game_logic/src/scenes/player_interaction.rs index 24e5659d..b9374575 100644 --- a/game/game_logic/src/scenes/player_interaction.rs +++ b/game/game_logic/src/scenes/player_interaction.rs @@ -181,7 +181,15 @@ impl PlayableScene { Color::GREEN, ); draw.draw_text( - format!("player: ({}, {}) size: {} map: ({}, {})", self.player.position.x,self.player.position.y,self.player.size,self.world_map.get_map_size().x,self.world_map.get_map_size().y).as_str(), + format!( + "player: ({}, {}) size: {} map: ({}, {})", + self.player.position.x, + self.player.position.y, + self.player.size, + self.world_map.get_map_size().x, + self.world_map.get_map_size().y + ) + .as_str(), 10, 50, 20, @@ -263,21 +271,24 @@ impl PlayableScene { for i in &self.world_colliders { if player.position.x - player_size <= i.position.x + i.size.x / 2.0 && player.position.x + player_size >= i.position.x + i.size.x / 2.0 - && player.position.y - player_size<= i.position.y + i.size.y / 2.0 + && player.position.y - player_size <= i.position.y + i.size.y / 2.0 && player.position.y + player_size >= i.position.y + i.size.x / 2.0 { - if player.velocity.x < 0.0 { - player.position.x = i.position.x + i.size.x / 2.0 + player_size; - } else if player.velocity.x > 0.0 { - player.position.x = i.position.x - i.size.x / 2.0 - player_size; - } - + // if player.velocity.x < 0.0 { + // player.position.x = i.position.x + i.size.x / 2.0 + player_size; + // } else if player.velocity.x > 0.0 { + // player.position.x = i.position.x - i.size.x / 2.0 - player_size; + // } + + player.position.x -= velocity_modifier.x; player.velocity.x = 0.0; break; } } - if player.position.x - player_size < 0.0 || player.position.x + player_size > self.world_map.get_map_size().x { + if player.position.x - player_size < 0.0 + || player.position.x + player_size > self.world_map.get_map_size().x + { if player.velocity.x < 0.0 { player.position.x = player_size; } else if player.velocity.x > 0.0 { @@ -291,20 +302,24 @@ impl PlayableScene { for i in &self.world_colliders { if player.position.x - player_size <= i.position.x + i.size.x / 2.0 && player.position.x + player_size >= i.position.x + i.size.x / 2.0 - && player.position.y - player_size<= i.position.y + i.size.y / 2.0 + && player.position.y - player_size <= i.position.y + i.size.y / 2.0 && player.position.y + player_size >= i.position.y + i.size.x / 2.0 { if player.velocity.y < 0.0 { player.position.y = i.position.y + i.size.y / 2.0 + player_size; - } else if player.velocity.x > 0.0 { + } else if player.velocity.y > 0.0 { player.position.y = i.position.y - i.size.y / 2.0 - player_size; } + player.position.y -= velocity_modifier.y; + player.velocity.y = 0.0; break; } } - if player.position.y + player_size > 0.0 || player.position.y - player_size < -self.world_map.get_map_size().y { + if player.position.y + player_size > 0.0 + || player.position.y - player_size < -self.world_map.get_map_size().y + { if player.velocity.y > 0.0 { player.position.y = -player_size; } else if player.velocity.y < 0.0 {