diff options
Diffstat (limited to 'games/rstnode/rst-client/src/state.rs')
-rw-r--r-- | games/rstnode/rst-client/src/state.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/games/rstnode/rst-client/src/state.rs b/games/rstnode/rst-client/src/state.rs new file mode 100644 index 000000000000..c55dc2faa6d6 --- /dev/null +++ b/games/rstnode/rst-client/src/state.rs @@ -0,0 +1,48 @@ +//! Game client state handling + +use crate::{ + graphics::entities::{Coordinates, NodeRndr}, + GameSettings, +}; +use ggez::{event::EventHandler, graphics, Context, GameResult}; +use rst_core::data::{Node, Owner, Upgrade}; +use std::sync::Arc; + +pub struct ClientState { + node: NodeRndr, +} + +impl ClientState { + pub fn new(_settings: &GameSettings) -> Self { + Self { + node: NodeRndr { + loc: Coordinates(250.0, 250.0), + inner: Arc::new(Node { + id: 0, + health: 100.into(), + max_health: 100.into(), + owner: Owner::Neutral, + type_: Upgrade::Base, + links: 0, + link_states: vec![], + buffer: vec![], + }), + }, + } + } +} + +impl EventHandler for ClientState { + fn update(&mut self, _ctx: &mut Context) -> GameResult<()> { + Ok(()) + } + + fn draw(&mut self, ctx: &mut Context) -> GameResult<()> { + graphics::clear(ctx, graphics::Color::from_rgb(15, 15, 15)); + + // Render the node + self.node.draw(ctx).unwrap(); + + graphics::present(ctx) + } +} |