1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use nalgebra as na;
use raylib::prelude::*;
use crate::asset_manager::load_texture_from_internal_data;
#[derive(Debug)]
pub struct Player {
pub position: na::Vector2<f32>,
pub velocity: na::Vector2<f32>,
pub size: f32,
pub active_texture: i32,
pub textures: Vec<Texture2D>,
}
impl Player {
pub fn new(
raylib_handle: &mut raylib::RaylibHandle,
thread: &raylib::RaylibThread,
position: na::Vector2<f32>,
) -> Self {
let textures = vec![
load_texture_from_internal_data(
raylib_handle,
thread,
"assets/chr/chr_cubee/chr_cubeeLarge.png",
)
.unwrap(),
load_texture_from_internal_data(
raylib_handle,
thread,
"assets/chr/chr_cubee/chr_cubeeMedium.png",
)
.unwrap(),
load_texture_from_internal_data(
raylib_handle,
thread,
"assets/chr/chr_cubee/chr_cubeeSmall.png",
)
.unwrap(),
];
Self {
position,
velocity: na::Vector2::zeros(),
size: 1.0,
active_texture: 0,
textures,
}
}
}