update for will

This commit is contained in:
Evan Pratten 2021-04-23 22:54:04 -04:00
parent 534c9bd800
commit 50634c7516
2 changed files with 21 additions and 2 deletions

View File

@ -7,6 +7,10 @@ use crate::{
use super::screen::Screen;
const NORMAL_PLAYER_SPEED: i32 = 4;
const BOOST_PLAYER_SPEED: i32 = NORMAL_PLAYER_SPEED * 2;
const CAMERA_FOLLOW_SPEED: f32 = 3.0;
pub enum InGameState {
BUYING,
SWIMMING,
@ -40,9 +44,22 @@ impl InGameScreen {
// Handle action buttons
let user_request_boost =
draw_handle.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON);
draw_handle.is_mouse_button_down(MouseButton::MOUSE_LEFT_BUTTON);
let user_request_action =
draw_handle.is_mouse_button_pressed(MouseButton::MOUSE_RIGHT_BUTTON);
// Move the player in their direction
let speed_multiplier = match user_request_boost && game_core.player.boost_percent >= 0.0 {
true => BOOST_PLAYER_SPEED as f32,
false => NORMAL_PLAYER_SPEED as f32
};
game_core.player.position += game_core.player.direction * speed_multiplier;
// Move the camera to follow the player
let direction_from_cam_to_player = player_screen_position;
// game_core.master_camera.offset -= direction_from_cam_to_player * CAMERA_FOLLOW_SPEED;
game_core.master_camera.target = game_core.player.position + 0;
}
fn render_player(

View File

@ -6,12 +6,14 @@ use raylib::math::Vector2;
pub struct Player {
pub position: Vector2,
pub direction: Vector2,
pub coins: u32
pub coins: u32,
pub boost_percent: f32
}
impl Player {
pub fn new() -> Self {
Self {
boost_percent: 1.0,
..Default::default()
}