mod ant; mod constants; mod food; use crate::ant::Ant; use crate::constants::{SCREEN_HEIGHT, SCREEN_WIDTH}; use crate::food::Food; use macroquad::prelude::*; fn window_conf() -> Conf { Conf { window_title: "Ants".to_string(), fullscreen: false, window_width: SCREEN_WIDTH, window_height: SCREEN_HEIGHT, ..Default::default() } } trait Drawable { fn draw(&self); } #[macroquad::main(window_conf)] async fn main() { let map = load_texture("map_scaled.png").await.unwrap(); let map_data = map.get_texture_data(); let mut ants = Ant::init(16); let mut food = Food::init(); loop { // actions ants.iter_mut().for_each(|ant| ant.walk(&map_data)); if is_key_down(KeyCode::Escape) || is_quit_requested() { return; } if is_mouse_button_down(MouseButton::Left) { let mouse = mouse_position(); food.push(Food::new(Vec2::new(mouse.0, mouse.1))); } // render clear_background(BEIGE); draw_texture(map, 0., 0., WHITE); ants.iter().for_each(|ant| ant.draw()); food.iter().for_each(|food| food.draw()); next_frame().await } }