diff --git a/game/dist/project-constants.json b/game/dist/project-constants.json index 46f8c02e..ec52701f 100644 --- a/game/dist/project-constants.json +++ b/game/dist/project-constants.json @@ -21,6 +21,7 @@ "max_velocity": 3, "acceleration": 2, "deceleration": 1, - "start_size": 0.8 + "start_size": 0.8, + "melt_speed": 0.00944443 } } diff --git a/game/game_logic/src/project_constants.rs b/game/game_logic/src/project_constants.rs index 6df497d3..dde085bb 100644 --- a/game/game_logic/src/project_constants.rs +++ b/game/game_logic/src/project_constants.rs @@ -43,6 +43,9 @@ pub struct PlayerConstants { /// Starting size of player in tiles pub start_size: f32, + + /// Base melting speed in percent per second + pub melt_speed: f32, } /// This structure is filled with the contents of `dist/project-constants.json` at runtime diff --git a/game/game_logic/src/scenes/player_interaction.rs b/game/game_logic/src/scenes/player_interaction.rs index ed8c8a40..b3c03a4d 100644 --- a/game/game_logic/src/scenes/player_interaction.rs +++ b/game/game_logic/src/scenes/player_interaction.rs @@ -78,7 +78,7 @@ impl PlayableScene { rotation: 0.0, zoom: 1.0, }, - last_update: SystemTime::UNIX_EPOCH, + last_update: SystemTime::now(), game_soundtrack, world_colliders, show_debug_info: false, @@ -134,13 +134,18 @@ impl PlayableScene { self.draw_ui(&mut draw, constants); // NOTE: If you want to trigger a cutscene, do it here by using one of: - // return MenuStateSignal::DoMeltedDeathCutscene { - // playtime: Utc::now().signed_duration_since(self.play_start_time), - // }; + // return MenuStateSignal::DoOceanCutscene { // playtime: Utc::now().signed_duration_since(self.play_start_time), // }; + // Handle Losing + if self.player.size < 0.15 { + return MenuStateSignal::DoMeltedDeathCutscene { + playtime: Utc::now().signed_duration_since(self.play_start_time), + }; + } + // Handle winning if self .world_map @@ -188,6 +193,14 @@ impl PlayableScene { let mouse_x = draw.get_mouse_x(); let mouse_y = draw.get_mouse_y(); + let current_temperature = self.world_map.sample_temperature_at( + self.player.position.component_mul(&na::Vector2::new(1.0, -1.0)) + ); + let mut current_temperature_val: f32 = 1.0; + if let Some(val) = current_temperature { + current_temperature_val = val; + } + // Optionally display debug info if draw.is_key_pressed(KeyboardKey::KEY_F3) { self.show_debug_info = !self.show_debug_info; @@ -231,6 +244,12 @@ impl PlayableScene { // 32, // Color::BLACK, // ); + let melt_amount = constants.player.melt_speed * (current_temperature_val)/(-247.51879); + + draw.draw_text( + format!("Funny Temperature: ({})[{}]", current_temperature_val, melt_amount).as_str(), + 10, 10, 20, Color::PAPAYAWHIP + ); } // Physics @@ -249,11 +268,11 @@ impl PlayableScene { let player = &mut self.player; - // NOTE: This is how to check friction and temperature let current_friction = self.world_map.sample_friction_at(player.position); - let current_temperature = self.world_map.sample_temperature_at(player.position); + let current_temperature = self.world_map.sample_temperature_at( + player.position.component_mul(&na::Vector2::new(1.0, -1.0)) + ); let map_size = self.world_map.get_map_size(); - // TODO: You can access the colission list with: self.world_colliders // Get input direction components let h_axis = raylib.is_key_down(KeyboardKey::KEY_D) as i8 @@ -354,10 +373,14 @@ impl PlayableScene { player.velocity.y = 0.0; } - player.size -= 0.001; - - player.size -= 0.001; + let mut current_temperature_val: f32 = -247.51879; + if let Some(val) = current_temperature { + current_temperature_val = val - 273.15; + } + let melt_amount = constants.player.melt_speed * (-247.51879)/(current_temperature_val); + player.size -= melt_amount * delta_time; + self.update_camera(raylib); }