From 23057dac837b2cb3c0901165e8139796e4dfd97a Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Fri, 1 Apr 2022 23:39:20 -0400 Subject: [PATCH 1/2] working on obj description format --- game/game_logic/Cargo.toml | 2 +- game/game_logic/src/model/mod.rs | 3 ++- game/game_logic/src/model/world_object.rs | 26 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 game/game_logic/src/model/world_object.rs diff --git a/game/game_logic/Cargo.toml b/game/game_logic/Cargo.toml index be0d2754..e6fb3ce5 100644 --- a/game/game_logic/Cargo.toml +++ b/game/game_logic/Cargo.toml @@ -25,4 +25,4 @@ thiserror = "1.0.30" approx = "0.5.1" poll-promise = { version = "0.1.0", features = ["tokio"] } tempfile = "3.3.0" -nalgebra = "0.30.1" \ No newline at end of file +nalgebra = { version = "0.30.1", features=["serde-serialize"]} \ No newline at end of file diff --git a/game/game_logic/src/model/mod.rs b/game/game_logic/src/model/mod.rs index d44230b1..f576cdb7 100644 --- a/game/game_logic/src/model/mod.rs +++ b/game/game_logic/src/model/mod.rs @@ -1 +1,2 @@ -pub mod player; \ No newline at end of file +pub mod player; +pub mod world_object; \ No newline at end of file diff --git a/game/game_logic/src/model/world_object.rs b/game/game_logic/src/model/world_object.rs new file mode 100644 index 00000000..44ef9a46 --- /dev/null +++ b/game/game_logic/src/model/world_object.rs @@ -0,0 +1,26 @@ +use nalgebra as na; +use serde::Deserialize; + +#[derive(Debug, Clone, Deserialize)] +pub struct PossiblyAnimatedTexture { + /// Signal if the texture is animated or static + pub animated: bool, + /// Relative file path from `dist` to the texture + pub rel_file_path: String, +} + +#[derive(Debug, Clone, Deserialize)] +pub struct WorldObject { + /// Object name. Must match the name of the texture + pub name: String, + /// Object variant name. Must match the name of the texture, or None if there is only one variant + pub variant_name: Option, + /// Object position. 1,1 being up and to the right + pub position: na::Vector2, + /// Object rotation, positive is clockwise + pub rotation_radians: f32, + /// The object's bottom texture + pub bottom_texture: PossiblyAnimatedTexture, + /// The object's top texture + pub top_texture: Option, +} From e1eccd2f9e0991ea23bc75384b9987ce0eec5e66 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sat, 2 Apr 2022 00:07:03 -0400 Subject: [PATCH 2/2] json backings --- game/game_logic/src/model/world_object.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/game/game_logic/src/model/world_object.rs b/game/game_logic/src/model/world_object.rs index 44ef9a46..ceb0fe9c 100644 --- a/game/game_logic/src/model/world_object.rs +++ b/game/game_logic/src/model/world_object.rs @@ -9,6 +9,17 @@ pub struct PossiblyAnimatedTexture { pub rel_file_path: String, } + +#[derive(Debug, Clone, Deserialize)] +pub struct ObjectCollider { + /// Position, relative to the object's center (north east is 1,1 south west is -1,-1) + pub position: na::Vector2, + /// Possible sizing + pub size: Option>, + /// Possible radius + pub radius: Option, +} + #[derive(Debug, Clone, Deserialize)] pub struct WorldObject { /// Object name. Must match the name of the texture @@ -23,4 +34,10 @@ pub struct WorldObject { pub bottom_texture: PossiblyAnimatedTexture, /// The object's top texture pub top_texture: Option, + /// colliders describing the object's footprint + pub footprint: Vec, + /// Colliders for physics + pub physics_colliders: Vec, + /// Temperature + pub temperature: Option, }