Merge Stash

This commit is contained in:
Silas Bartha 2022-04-03 22:59:51 -04:00
parent 2d3e05f6f7
commit bd713c3e75
No known key found for this signature in database
GPG Key ID: 9323054A4EA1EA6C
3 changed files with 38 additions and 11 deletions

View File

@ -21,6 +21,7 @@
"max_velocity": 3, "max_velocity": 3,
"acceleration": 2, "acceleration": 2,
"deceleration": 1, "deceleration": 1,
"start_size": 0.8 "start_size": 0.8,
"melt_speed": 0.00944443
} }
} }

View File

@ -43,6 +43,9 @@ pub struct PlayerConstants {
/// Starting size of player in tiles /// Starting size of player in tiles
pub start_size: f32, 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 /// This structure is filled with the contents of `dist/project-constants.json` at runtime

View File

@ -78,7 +78,7 @@ impl PlayableScene {
rotation: 0.0, rotation: 0.0,
zoom: 1.0, zoom: 1.0,
}, },
last_update: SystemTime::UNIX_EPOCH, last_update: SystemTime::now(),
game_soundtrack, game_soundtrack,
world_colliders, world_colliders,
show_debug_info: false, show_debug_info: false,
@ -134,13 +134,18 @@ impl PlayableScene {
self.draw_ui(&mut draw, constants); self.draw_ui(&mut draw, constants);
// NOTE: If you want to trigger a cutscene, do it here by using one of: // 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 { // return MenuStateSignal::DoOceanCutscene {
// playtime: Utc::now().signed_duration_since(self.play_start_time), // 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 // Handle winning
if self if self
.world_map .world_map
@ -188,6 +193,14 @@ impl PlayableScene {
let mouse_x = draw.get_mouse_x(); let mouse_x = draw.get_mouse_x();
let mouse_y = draw.get_mouse_y(); 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 // Optionally display debug info
if draw.is_key_pressed(KeyboardKey::KEY_F3) { if draw.is_key_pressed(KeyboardKey::KEY_F3) {
self.show_debug_info = !self.show_debug_info; self.show_debug_info = !self.show_debug_info;
@ -231,6 +244,12 @@ impl PlayableScene {
// 32, // 32,
// Color::BLACK, // 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 // Physics
@ -249,11 +268,11 @@ impl PlayableScene {
let player = &mut self.player; 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_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(); let map_size = self.world_map.get_map_size();
// TODO: You can access the colission list with: self.world_colliders
// Get input direction components // Get input direction components
let h_axis = raylib.is_key_down(KeyboardKey::KEY_D) as i8 let h_axis = raylib.is_key_down(KeyboardKey::KEY_D) as i8
@ -354,10 +373,14 @@ impl PlayableScene {
player.velocity.y = 0.0; player.velocity.y = 0.0;
} }
player.size -= 0.001; let mut current_temperature_val: f32 = -247.51879;
if let Some(val) = current_temperature {
player.size -= 0.001; 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); self.update_camera(raylib);
} }