that's multiplayer. that counts

main
_ 2021-05-08 23:38:33 +00:00
parent 2135bb0f24
commit 06c173e6da
1 changed files with 42 additions and 34 deletions

View File

@ -24,11 +24,14 @@ async fn main () -> anyhow::Result <()> {
let connected_players = Arc::new (Mutex::new (vec! [])); let connected_players = Arc::new (Mutex::new (vec! []));
use opengl_rust::timestep::TimeStep; {
let connected_players = Arc::clone (&connected_players);
tokio::spawn (async move {
let mut player_seq = 0; let mut player_seq = 0;
let incoming_conn = incoming.next ().await.unwrap ();
let new_conn = incoming_conn.await.unwrap (); while let Some (incoming_conn) = incoming.next ().await {
let new_conn = incoming_conn.await?;
println! ( println! (
"[server] connection accepted: addr={}", "[server] connection accepted: addr={}",
new_conn.connection.remote_address () new_conn.connection.remote_address ()
@ -66,8 +69,13 @@ async fn main () -> anyhow::Result <()> {
} }
player_seq += 1; player_seq += 1;
}
let mut time_step = TimeStep::new (120, 1000); Ok::<_, anyhow::Error> (())
});
}
let mut time_step = opengl_rust::timestep::TimeStep::new (120, 1000);
let mut state = NetworkedState { let mut state = NetworkedState {
positions: vec! [ positions: vec! [
(32.0, 32.0), (32.0, 32.0),