aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorlamp2023-03-05 21:27:40 +0000
committerlamp2023-03-05 21:27:40 +0000
commit4fb356822ef98241d2e44b0b0bd31d7f214f9f20 (patch)
treeded1de844e9f4303c79d4bcea18d89e939215cf8 /src/util.rs
initmain
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
new file mode 100644
index 0000000..dcd2b72
--- /dev/null
+++ b/src/util.rs
@@ -0,0 +1,45 @@
+use std::rc::Rc;
+
+use crate::vec2::Vec2;
+use crate::texture::Texture;
+
+#[derive(Clone)]
+pub enum Side {
+ X,
+ Y,
+}
+
+pub enum Orientation {
+ XAxis,
+ YAxis,
+}
+
+#[derive(Clone)]
+pub enum Step {
+ Left,
+ Right,
+}
+
+impl Step {
+ pub fn value(&self) -> i32 {
+ match self {
+ Step::Left => -1,
+ Step::Right => 1,
+ }
+ }
+
+ pub fn from(value: bool) -> Step {
+ match value {
+ true => Step::Left,
+ false => Step::Right,
+ }
+ }
+}
+
+pub struct Sprite {
+ pub position: Vec2<f64>,
+ pub texture: Rc<Texture>,
+ pub vertical_offset: f64,
+ pub scale_factor: Vec2<f64>,
+ pub distance_from_camera: f64,
+}