From 09c776ba3f1c6165927acf3b2da2b4e9b8fd0d6c Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sat, 24 Apr 2021 12:16:38 -0400 Subject: [PATCH] resizing everything --- src/entities/fish.rs | 6 +-- src/gamecore.rs | 2 +- src/logic/ingame/mod.rs | 1 + src/logic/ingame/playerlogic.rs | 79 +++++++++++++++++---------------- src/player.rs | 4 +- 5 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/entities/fish.rs b/src/entities/fish.rs index 869fb61..f78fbb3 100644 --- a/src/entities/fish.rs +++ b/src/entities/fish.rs @@ -3,8 +3,8 @@ use raylib::prelude::*; use crate::{gamecore::GameCore, lib::utils::triangles::rotate_vector, player::Player}; -const FISH_FOLLOW_PLAYER_DISTANCE: f32 = 80.0; -const FISH_FOLLOW_PLAYER_SPEED: f32 = 2.0; +const FISH_FOLLOW_PLAYER_DISTANCE: f32 = 30.0; +const FISH_FOLLOW_PLAYER_SPEED: f32 = 1.8; const FISH_FOLLOW_PLAYER_SPEED_FAST: f32 = FISH_FOLLOW_PLAYER_SPEED * 3.0; const FISH_ATTACH_RADIUS: f32 = 20.0; @@ -74,7 +74,7 @@ impl FishEntity { direction_to_player.normalize(); // Handle player picking up fish - if player.position.distance_to(self.position).abs() <= player.size.y * 1.2 { + if player.position.distance_to(self.position).abs() <= player.size.y * 2.2 { self.following_player = true; } diff --git a/src/gamecore.rs b/src/gamecore.rs index 2cd14c7..a29e2fa 100644 --- a/src/gamecore.rs +++ b/src/gamecore.rs @@ -119,7 +119,7 @@ impl GameCore { offset: Vector2::zero(), target: Vector2::zero(), rotation: 0.0, - zoom: 1.0, + zoom: 2.0, }, show_simple_debug_info: false, world: world, diff --git a/src/logic/ingame/mod.rs b/src/logic/ingame/mod.rs index fb93e50..843134e 100644 --- a/src/logic/ingame/mod.rs +++ b/src/logic/ingame/mod.rs @@ -61,6 +61,7 @@ impl Screen for InGameScreen { x: (win_width as f32 / 2.0), y: (win_height as f32 / 2.0), }; + let camera_window_center = window_center * (1.0 / game_core.master_camera.zoom); // Update player movement playerlogic::update_player_movement(draw_handle, game_core, window_center); diff --git a/src/logic/ingame/playerlogic.rs b/src/logic/ingame/playerlogic.rs index 37c0a16..0234ec0 100644 --- a/src/logic/ingame/playerlogic.rs +++ b/src/logic/ingame/playerlogic.rs @@ -5,10 +5,10 @@ use crate::{ pallette::{TRANSLUCENT_WHITE_128, TRANSLUCENT_WHITE_64, TRANSLUCENT_WHITE_96}, }; -const NORMAL_PLAYER_SPEED: i32 = 4; +const NORMAL_PLAYER_SPEED: i32 = 3; const BOOST_PLAYER_SPEED: i32 = NORMAL_PLAYER_SPEED * 2; const CAMERA_FOLLOW_SPEED: f32 = 0.7; -const TURN_SPEED: f32 = 0.05; +const TURN_SPEED: f32 = 0.15; const BOOST_DECREASE_PER_SECOND: f32 = 0.75; const BOOST_REGEN_PER_SECOND: f32 = 0.25; const BREATH_DECREASE_PER_SECOND: f32 = 0.01; @@ -27,45 +27,45 @@ pub fn update_player_movement( let raw_movement_direction = mouse_world_pose - game_core.player.position; let mut normalized_movement_direction = raw_movement_direction; normalized_movement_direction.normalize(); - - let tau: f32 = PI as f32 * 2.0; - // get angles as floats - let mut player_angle: f32 = Vector2::zero().angle_to(game_core.player.direction); - let mut desired_angle: f32 = Vector2::zero().angle_to(normalized_movement_direction); - // make angle positive - if desired_angle < 0.0 { - desired_angle += tau; - } + let tau: f32 = PI as f32 * 2.0; + // get angles as floats + let mut player_angle: f32 = Vector2::zero().angle_to(game_core.player.direction); + let mut desired_angle: f32 = Vector2::zero().angle_to(normalized_movement_direction); - // turn towards mouse at turn speed - if player_angle % tau > desired_angle { - if (player_angle % tau) - desired_angle > PI as f32 { - player_angle += TURN_SPEED; - } else { - player_angle -= TURN_SPEED; - } + // make angle positive + if desired_angle < 0.0 { + desired_angle += tau; + } + + // turn towards mouse at turn speed + if player_angle % tau > desired_angle { + if (player_angle % tau) - desired_angle > PI as f32 { + player_angle += TURN_SPEED; } else { - if desired_angle - (player_angle % tau) > PI as f32 { - player_angle -= TURN_SPEED; - } else { - player_angle += TURN_SPEED; - } + player_angle -= TURN_SPEED; } + } else { + if desired_angle - (player_angle % tau) > PI as f32 { + player_angle -= TURN_SPEED; + } else { + player_angle += TURN_SPEED; + } + } - // snap to mouse if close enough - if f32::abs(player_angle - desired_angle) < (TURN_SPEED * 1.1) { - player_angle = desired_angle; - } - if player_angle > tau { - player_angle -= tau; - } - if player_angle < 0.0 { - player_angle += tau; - } + // snap to mouse if close enough + if f32::abs(player_angle - desired_angle) < (TURN_SPEED * 1.1) { + player_angle = desired_angle; + } + if player_angle > tau { + player_angle -= tau; + } + if player_angle < 0.0 { + player_angle += tau; + } - // set angle - game_core.player.direction = Vector2::new(f32::cos(player_angle), f32::sin(player_angle)); + // set angle + game_core.player.direction = Vector2::new(f32::cos(player_angle), f32::sin(player_angle)); // In the case the player is in "null", just jump the camera to them if game_core.player.position == Vector2::zero() { @@ -135,9 +135,12 @@ pub fn render_player(context_2d: &mut RaylibMode2D, game_core: TRANSLUCENT_WHITE_64, ); context_2d.draw_ring( - player.position, - boost_ring_max_radius - 2.0, - boost_ring_max_radius + 2.0, + Vector2 { + x: player.position.x as i32 as f32, + y: player.position.y as i32 as f32, + }, + boost_ring_max_radius , + boost_ring_max_radius + 1.0, 0, (360.0 * player.breath_percent) as i32, 0, diff --git a/src/player.rs b/src/player.rs index a455e9b..d37f539 100644 --- a/src/player.rs +++ b/src/player.rs @@ -17,8 +17,8 @@ impl Player { Self { boost_percent: 1.0, size: Vector2 { - x: 11.0 * 4.0, - y: 21.0 * 4.0 + x: 11.0, + y: 21.0 }, breath_percent: 1.0, ..Default::default()