mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
31 lines
811 B
Rust
31 lines
811 B
Rust
use std::ops::{Add, Mul, Sub};
|
|
use vek::*;
|
|
use veloren_world::sim::Settlement;
|
|
use rand::thread_rng;
|
|
|
|
const W: usize = 640;
|
|
const H: usize = 480;
|
|
|
|
fn main() {
|
|
let mut win =
|
|
minifb::Window::new("City Viewer", W, H, minifb::WindowOptions::default()).unwrap();
|
|
|
|
let settlement = Settlement::generate(&mut thread_rng());
|
|
|
|
while win.is_open() {
|
|
let mut buf = vec![0; W * H];
|
|
|
|
for i in 0..W {
|
|
for j in 0..H {
|
|
let pos = Vec2::new(i as f32, j as f32) * 0.002;
|
|
|
|
let seed = settlement.get_at(pos).map(|b| b.seed).unwrap_or(0);
|
|
|
|
buf[j * W + i] = u32::from_le_bytes([(seed >> 0) as u8, (seed >> 8) as u8, (seed >> 16) as u8, (seed >> 24) as u8]);
|
|
}
|
|
}
|
|
|
|
win.update_with_buffer(&buf).unwrap();
|
|
}
|
|
}
|