blob: 5666a751e55d2516422ff759b97871990f436c63 (
plain)
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
|
use geometry::*;
use hitbox::*;
use asset_id::*;
#[derive(Clone)]
pub struct Home {
pub pos: Vec2d,
pub animation_time: f64,
pub sprite: SpriteId
}
impl Home {
pub fn new(x: f64, y: f64) -> Home {
Home {
pos: Vec2d::new(x, y),
animation_time: 0.,
sprite: SpriteId::Sleepypug1
}
}
pub fn advance(&mut self, seconds: f64) {
let scale = 0.5;
self.animation_time = (self.animation_time + scale * seconds).fract();
self.sprite = if self.animation_time < 0.3 {
SpriteId::Sleepypug1
} else if self.animation_time < 0.4 {
SpriteId::Sleepypug2
} else if self.animation_time < 0.5 {
SpriteId::Sleepypug3
} else if self.animation_time < 0.8 {
SpriteId::Sleepypug4
} else if self.animation_time < 0.9 {
SpriteId::Sleepypug3
} else {
SpriteId::Sleepypug2
} ;
}
}
impl CircleHitbox for Home {
fn pos(&self) -> Vec2d {
self.pos
}
fn radius(&self) -> f64 {
100.
}
}
|