ants/src/main.rs

37 lines
833 B
Rust
Raw Normal View History

2021-10-03 19:49:30 +00:00
mod ant;
mod constants;
use macroquad::prelude::*;use crate::ant::init_ants;
fn window_conf() -> Conf {
Conf {
window_title: "Ants".to_string(),
fullscreen: false,
window_width: 1280,
window_height: 720,
..Default::default()
}
2021-10-03 10:19:24 +00:00
}
#[macroquad::main(window_conf)]
async fn main() {
let map = load_texture("map_scaled.png").await.unwrap();
2021-10-03 19:39:24 +00:00
let map_data = map.get_texture_data();
let mut ants = init_ants(16);
2021-10-03 19:59:18 +00:00
loop {
// actions
2021-10-03 19:39:24 +00:00
ants.iter_mut().for_each(|ant| ant.walk(&map_data));
if is_key_down(KeyCode::Escape) || is_quit_requested() {
return;
}
// render
clear_background(BEIGE);
draw_texture(map, 0., 0., WHITE);
ants.iter().for_each(|ant| ant.draw());
next_frame().await
}
}