From 79c8b9ab441493e3b3a37a59263f66896c9c90b3 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 7 Feb 2021 16:44:44 +0100 Subject: rstnode: basic asset loading and prototype sprite rendering * restructure assets directory * implement asset loading and dynamic conversion to sprites * reload sprites with unique URIs to load at runtime * provide an updated renderer API to give access to client state * use new APIs to draw a single node frame on screen * use colour APIs to dynamically change node frame colour --- games/rstnode/rst-client/src/error.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 games/rstnode/rst-client/src/error.rs (limited to 'games/rstnode/rst-client/src/error.rs') diff --git a/games/rstnode/rst-client/src/error.rs b/games/rstnode/rst-client/src/error.rs new file mode 100644 index 000000000000..08266bd5e591 --- /dev/null +++ b/games/rstnode/rst-client/src/error.rs @@ -0,0 +1,24 @@ +//! Various errors that can occur + +use std::{ + error::Error, + fmt::{self, Display, Formatter}, +}; + +/// Error loading an asset +#[derive(Clone, Debug)] +pub struct LoadError(String); + +impl<'s> From<&'s str> for LoadError { + fn from(s: &'s str) -> Self { + Self(s.into()) + } +} + +impl Display for LoadError { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl Error for LoadError {} -- cgit v1.2.3