aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/graphics/mod.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2021-02-07 16:44:44 +0100
committerKatharina Fey <kookie@spacekookie.de>2021-02-07 16:44:44 +0100
commit79c8b9ab441493e3b3a37a59263f66896c9c90b3 (patch)
treeca111686fa202369a5730ff8151480b04e391cbb /games/rstnode/rst-client/src/graphics/mod.rs
parentf5b36ff6b99256030201c878608a07d163b4c802 (diff)
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
Diffstat (limited to 'games/rstnode/rst-client/src/graphics/mod.rs')
-rw-r--r--games/rstnode/rst-client/src/graphics/mod.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/games/rstnode/rst-client/src/graphics/mod.rs b/games/rstnode/rst-client/src/graphics/mod.rs
index 8118207d70af..095e66f1ad1f 100644
--- a/games/rstnode/rst-client/src/graphics/mod.rs
+++ b/games/rstnode/rst-client/src/graphics/mod.rs
@@ -8,9 +8,25 @@
pub mod entities;
pub mod ui;
+use crate::state::ClientState;
+use ggez::{Context, GameResult};
+
/// A utility module to include everything required to implement a
/// graphics entity
pub(self) mod prelude {
- pub use ggez::{event::EventHandler, graphics::{self, Drawable, DrawParam, Mesh, DrawMode}, Context, GameResult};
+ pub use ggez::{
+ event::EventHandler,
+ graphics::{self, DrawMode, DrawParam, Drawable, Mesh},
+ Context, GameResult,
+ };
pub use mint::Point2;
+
+ pub use super::Renderer;
+ pub use crate::state::ClientState;
+}
+
+/// A rendering trait which is given graphics context, and game state
+pub trait Renderer {
+ fn update(&mut self, _state: &mut ClientState, _ctx: &mut Context) -> GameResult<()>;
+ fn draw(&self, _state: &ClientState, _ctx: &mut Context) -> GameResult<()>;
}