Skip to content

Instantly share code, notes, and snippets.

@LucioFranco
Created October 20, 2018 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucioFranco/28b76392ed7d548c5e2af1495c0bfd76 to your computer and use it in GitHub Desktop.
Save LucioFranco/28b76392ed7d548c5e2af1495c0bfd76 to your computer and use it in GitHub Desktop.
// This is the position of some entity.
// It is syncable but has no reliability guarentees.
// Questions:
// - How do we let the server determine values and
// verify them and replicate them properly?
#[derive(Deserialize, Serialize, Sync)]
struct Position {
x: u16,
y: u16,
}
// This component would be synced and replicated
// reliably accross all clients.
// Questions:
// - How do we want to differentiate between a producer and a consumer
// of this type of entity? So what does this look like on the server side
// and the client side?
#[derive(Deserialize, Serialize, SyncReliable)]
struct Score(u8, u8);
fn main() -> Result<()> {
//...
let game_data = GameDataBuilder::default()
//...
.with_bundle(NetworkBundle::new("0.0.0.0:12345")))?
//...
let mut game = Application::build("./", State1)?
.with_frame_limit(
FrameRateLimitStrategy::SleepAndYield(Duration::from_millis(2)),
1,
).build(game_data)?;
game.run();
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment