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
|
use ggez::graphics::spritebatch::SpriteBatch;
use ggez::nalgebra::Point2;
pub trait Operable {
fn update(&mut self);
fn draw(&self, spritebatch: &mut SpriteBatch);
}
#[derive(Clone)]
pub struct Entity {
pub position: Point2<f32>,
pub spawn: Point2<f32>,
pub action: Action,
pub map_dimensions: (f32, f32),
}
impl Entity {
pub fn new(spawn: Point2<f32>, map_dimensions: (f32, f32)) -> Entity {
Entity {
spawn,
action: Action::IdleLeft,
position: spawn,
map_dimensions,
}
}
}
#[derive(Clone, Hash, Eq, PartialEq)]
pub enum Action {
IdleLeft,
IdleRight,
MovingUp,
MovingDown,
MovingLeft,
MovingRight,
MovingUpLeft,
MovingUpRight,
MovingDownLeft,
MovingDownRight,
}
|