obstacle.rs 659 Bytes
Newer Older
Grisu's avatar
Grisu committed
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
#[derive(Clone, Copy)]
pub struct Obstacle {
    w: f32,
    h: f32,
    // TODO replace with angle (we can have rotated colliders now)
    pub orientation: bool, // true means horizontal, false vertical
}

impl Obstacle {
    pub fn new(orientation: bool) -> Obstacle {
        Obstacle {
            w: 200.0,
            h: 20.0,
            orientation: orientation,
        }
    }

    pub fn width(&self) -> f32 {
        if self.orientation {
            self.w
        } else {
            self.h
        }
    }
    pub fn height(&self) -> f32 {
        if self.orientation {
            self.h
        } else {
            self.w
        }
    }
}