diff options
author | Katharina Fey <kookie@spacekookie.de> | 2021-02-07 21:12:22 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2021-02-07 21:12:22 +0100 |
commit | 0472f0fb50ffb945c83d662cd21b994562bee12d (patch) | |
tree | 58a5dfb1cc0d908c99ba50f5fdf8f7f0ebebd8b7 /games/rstnode/rst-client/src/graphics/entities/mod.rs | |
parent | 2d026c19ab9af91e316448bb74bfa27e0e295077 (diff) |
rstnode: some client cleanups and better colour handling
Diffstat (limited to 'games/rstnode/rst-client/src/graphics/entities/mod.rs')
-rw-r--r-- | games/rstnode/rst-client/src/graphics/entities/mod.rs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/games/rstnode/rst-client/src/graphics/entities/mod.rs b/games/rstnode/rst-client/src/graphics/entities/mod.rs index 17f26a8e5a70..a3289f6f412d 100644 --- a/games/rstnode/rst-client/src/graphics/entities/mod.rs +++ b/games/rstnode/rst-client/src/graphics/entities/mod.rs @@ -3,9 +3,10 @@ //! Generally the naming convention should be: `{type}Rndr` //! (`Renderer`, but shorter). +use crate::color; use super::prelude::*; -use rst_core::data::Node; +use rst_core::data::{Owner, Node, Color}; use std::sync::Arc; /// A set of universal X/Y coordinates @@ -29,23 +30,19 @@ impl Renderer for NodeRndr { fn draw(&self, s: &ClientState, ctx: &mut Context) -> GameResult<()> { let frame = s.assets().find("frame/frame_s").unwrap(); + let icon = s.assets().find("relay/relay1").unwrap(); + + let x = self.loc.0 - frame.width() as f32; + let y = self.loc.1 - frame.height() as f32; + + let color = match self.inner.owner { + Owner::Player(ref p) => color::to(p.color), + Owner::Neutral => color::to(Color::white()), + }; + + frame.draw(ctx, DrawParam::new().dest([x, y]).color(color))?; + icon.draw(ctx, DrawParam::new().dest([x, y]).color(color))?; - frame.draw( - ctx, - DrawParam::new().dest([256.0, 256.0]).color(graphics::RED), - )?; - - let circ = Mesh::new_circle( - ctx, - DrawMode::fill(), - Point2::from(&self.loc), - 64.0, - 0.1, - graphics::WHITE, - ) - .unwrap(); - - circ.draw(ctx, DrawParam::new()).unwrap(); Ok(()) } } |