mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
Add player entity
This commit is contained in:
parent
6ca737f36c
commit
5a6fe33e1e
7 changed files with 150 additions and 31 deletions
24
src/game/player.rs
Normal file
24
src/game/player.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use s2dc::{vec2, MobileEntity};
|
||||
|
||||
use crate::{
|
||||
math::{WorldPos, TILE_SIZE},
|
||||
world::{TilePos, TilePosScalar},
|
||||
};
|
||||
|
||||
pub struct Player {
|
||||
pub col_en: MobileEntity,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
pub fn new_at(pos: WorldPos) -> Self {
|
||||
Self {
|
||||
col_en: MobileEntity::from_pos_and_bb(vec2(pos.x as i32, pos.y as i32), vec2(15, 24)),
|
||||
}
|
||||
}
|
||||
pub fn center_tp(&self) -> TilePos {
|
||||
TilePos {
|
||||
x: (self.col_en.en.pos.x / TILE_SIZE as i32) as TilePosScalar,
|
||||
y: (self.col_en.en.pos.y / TILE_SIZE as i32) as TilePosScalar,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue