progress bars

This commit is contained in:
Vinzenz Schroeter 2025-07-05 13:36:21 +02:00
commit fe4543ae41
6 changed files with 142 additions and 68 deletions

View file

@ -1,13 +1,13 @@
use crate::command_queue::PacketQueue;
use bar::Bar;
use game_state::GameState;
use servicepoint::{ClearCommand, Origin, UdpSocketExt};
use crate::queue::PacketQueue;
use game::Game;
use servicepoint::{ClearCommand, UdpSocketExt, FRAME_PACING};
use std::net::UdpSocket;
use std::thread::sleep;
use std::time::{Duration, Instant};
mod bar;
mod command_queue;
mod game_state;
mod queue;
mod game;
mod label;
type Currency = f64;
@ -21,13 +21,13 @@ trait GenerateCommands {
fn generate_commands(&self, queue: &mut impl PacketQueue);
}
fn main() {
let mut state = GameState {
currency: 0f64,
first_step: Bar::new(1f64, Origin::new(0, 1)),
};
const DESTINATION: &str = "127.0.0.1:2342";
//const DESTINATION: &str = "172.23.42.29:2342";
let mut connection = UdpSocket::bind_connect("127.0.0.1:2342").unwrap();
fn main() {
let mut state = Game::new();
let mut connection = UdpSocket::bind_connect(DESTINATION).unwrap();
connection.send_command(ClearCommand);
let mut last_refresh = Instant::now();
loop {
@ -37,7 +37,8 @@ fn main() {
(state, _) = state.progress(delta);
connection.send_command(ClearCommand);
state.generate_commands(&mut connection);
sleep(FRAME_PACING);
}
}