55 lines
1.1 KiB
Rust
55 lines
1.1 KiB
Rust
use super::controls::InputState;
|
|
use raylib::prelude::*;
|
|
|
|
#[derive(Default)]
|
|
pub struct Player {
|
|
pub position: Vector2,
|
|
width: f32,
|
|
height: f32,
|
|
speed: f32,
|
|
jump_velocity: f32,
|
|
grounded: bool,
|
|
}
|
|
|
|
impl Player {
|
|
fn new(
|
|
position: Vector2,
|
|
width: f32,
|
|
height: f32,
|
|
speed: f32,
|
|
jump_velocity: f32,
|
|
grounded: bool,
|
|
) -> Self {
|
|
Self {
|
|
position,
|
|
width,
|
|
height,
|
|
speed,
|
|
jump_velocity,
|
|
grounded,
|
|
}
|
|
}
|
|
|
|
pub fn handle_input(&mut self, input: &InputState) {
|
|
// Da inpoot handol))
|
|
if input.right {
|
|
self.position.x += 2.0;
|
|
} else if input.left {
|
|
self.position.x -= 2.0;
|
|
} else if input.down {
|
|
self.position.y += 4.0;
|
|
}
|
|
}
|
|
|
|
pub fn handle_jump(&mut self, input: &InputState) {
|
|
if input.jump {
|
|
self.position.y -= 10.0;
|
|
}
|
|
}
|
|
|
|
pub fn rect(&self) -> Rectangle {
|
|
todo!()
|
|
// Collision bawx n shi
|
|
}
|
|
}
|