library

Online co-op book organization video game
git clone https://git.bradleygannon.com/library.git
Log | Files | Refs

main.rs (1294B)


      1 use std::{
      2     collections::VecDeque,
      3     sync::mpsc::{Receiver, Sender},
      4     time::{Duration, Instant, SystemTime},
      5 };
      6 
      7 use common::game::{Action, Response, state::GameState};
      8 use macroquad::prelude::*;
      9 use uuid::Uuid;
     10 
     11 use crate::{
     12     render::{Camera, SCREEN_HEIGHT_PX, SCREEN_WIDTH_PX},
     13     run::Config,
     14     state::ViewMode,
     15 };
     16 
     17 mod input;
     18 mod net;
     19 mod render;
     20 mod run;
     21 mod state;
     22 
     23 #[derive(Debug)]
     24 struct ClientState {
     25     mode: ViewMode,
     26     camera: Camera,
     27     game: GameState,
     28     old_game: GameState,
     29     interpolated_game: GameState,
     30     local_player_id: Option<Uuid>,
     31     sequence_number: u32,
     32     unresponded_actions: VecDeque<Action>,
     33     interpolation_basis: SystemTime,
     34     debug_view: bool,
     35     t0: Instant,
     36     t1: Instant,
     37     dt: Duration,
     38     tx: Option<Sender<Action>>,
     39     rx: Option<Receiver<Response>>,
     40     config: Config,
     41     menu_error: String,
     42     first_frame: bool,
     43     selected_inventory_book: usize,
     44 }
     45 
     46 #[macroquad::main("Library")]
     47 async fn main() {
     48     request_new_screen_size(SCREEN_WIDTH_PX, SCREEN_HEIGHT_PX);
     49 
     50     let mut client = ClientState::default();
     51 
     52     loop {
     53         match client.view_mode() {
     54             ViewMode::Menu => client.run_menu_frame(),
     55             ViewMode::Game => client.run_game_frame(),
     56         }
     57         next_frame().await;
     58     }
     59 }