use std::{ env::args, f32::consts::PI, fs::read_to_string, io::{BufWriter, Write, stdout}, time::Instant, }; fn main() { let mut out = BufWriter::new(stdout()); let objects = parse_file(&read_to_string(&args().nth(1).unwrap()).unwrap()); let start = Instant::now(); loop { let time = start.elapsed().as_secs_f32(); let mut points = Vec::new(); for h in &objects { let t = h.time as f32 / 1000.; let trel = time - t; if trel > 0. || trel < -1. { continue; } let x = h.x as f32 / 512.; let y = h.y as f32 / 384.; let r = 0.1 + trel / -10.; for i in 0..20 { let t = i as f32 / 20. * PI * 2.; points.push((x + t.sin() * r, y + t.cos() * r)); } } for (x, y) in points { out.write_all(&f32::to_le_bytes(x)).unwrap(); out.write_all(&f32::to_le_bytes(y)).unwrap(); } } } struct HitObject { x: i32, y: i32, time: i32, } fn parse_file(s: &str) -> Vec { let mut obs = Vec::new(); let b = s.split_once("[HitObjects]").unwrap().1; for line in b.lines() { if line.is_empty() { continue; } let mut toks = line.split(","); let x = toks.next().unwrap().parse().unwrap(); let y = toks.next().unwrap().parse().unwrap(); let time = toks.next().unwrap().parse().unwrap(); obs.push(HitObject { x, y, time }) } obs }