BANG BIG PEANITS
This commit is contained in:
54
src/player.rs
Normal file
54
src/player.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user