aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'games/rstnode/rst-client/src/state.rs')
-rw-r--r--games/rstnode/rst-client/src/state.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/games/rstnode/rst-client/src/state.rs b/games/rstnode/rst-client/src/state.rs
index b1b5e89f3d13..d3b5bbcc3d7b 100644
--- a/games/rstnode/rst-client/src/state.rs
+++ b/games/rstnode/rst-client/src/state.rs
@@ -7,6 +7,7 @@ use crate::{
Renderer,
},
input::InputHandle,
+ viewport::Viewport,
GameSettings,
};
use ggez::{event::EventHandler, graphics, Context, GameResult};
@@ -17,6 +18,7 @@ pub struct ClientState {
assets: Assets,
settings: GameSettings,
input: InputHandle,
+ vp: Viewport,
// Game state
node: NodeRndr,
@@ -27,6 +29,7 @@ impl ClientState {
Self {
assets,
settings,
+ vp: Viewport::new(),
input: InputHandle::new(),
node: NodeRndr {
loc: Coordinates(512.0, 512.0),
@@ -49,6 +52,10 @@ impl ClientState {
}
}
+ pub fn viewport(&mut self) -> &mut Viewport {
+ &mut self.vp
+ }
+
pub fn assets(&self) -> &Assets {
&self.assets
}
@@ -56,7 +63,16 @@ impl ClientState {
impl EventHandler for ClientState {
fn update(&mut self, ctx: &mut Context) -> GameResult<()> {
+ // TODO: get simulation updates
+
+ // Get new input state
self.input.update(ctx)?;
+
+ // Apply inputs to viewpoirt
+ self.vp.apply(ctx, &self.input)?;
+
+ // Update viewport
+ self.vp.update(ctx)?;
Ok(())
}