aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/graphics/entities
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/entities
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/entities')
-rw-r--r--games/rstnode/rst-client/src/graphics/entities/mod.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/games/rstnode/rst-client/src/graphics/entities/mod.rs b/games/rstnode/rst-client/src/graphics/entities/mod.rs
index d3536d4f5fc2..17f26a8e5a70 100644
--- a/games/rstnode/rst-client/src/graphics/entities/mod.rs
+++ b/games/rstnode/rst-client/src/graphics/entities/mod.rs
@@ -22,20 +22,28 @@ pub struct NodeRndr {
pub inner: Arc<Node>,
}
-impl EventHandler for NodeRndr {
- fn update(&mut self, _: &mut Context) -> GameResult<()> {
+impl Renderer for NodeRndr {
+ fn update(&mut self, _: &mut ClientState, _: &mut Context) -> GameResult<()> {
Ok(())
}
- fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
+ fn draw(&self, s: &ClientState, ctx: &mut Context) -> GameResult<()> {
+ let frame = s.assets().find("frame/frame_s").unwrap();
+
+ 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),
- 128.0,
+ 64.0,
0.1,
graphics::WHITE,
- ).unwrap();
+ )
+ .unwrap();
circ.draw(ctx, DrawParam::new()).unwrap();
Ok(())