use macroquad::{ prelude::*, texture::draw_texture, window::{clear_background, next_frame, screen_height, screen_width}, }; struct Position { x: f32, y: f32, forward: bool, speed: f32, } #[macroquad::main("star in svg")] async fn main() { let svg_data = " Text "; let texture = quad_svg::svg_to_texture(&svg_data); let mut positions: Vec = vec![]; for _i in 0..100 { positions.push(Position { x: rand::gen_range(0.0, screen_width() - texture.width()), y: rand::gen_range(0.0, screen_height() - texture.height()), forward: rand::gen_range(0, 2) == 1, speed: rand::gen_range(0.5, 5.0), }) } loop { clear_background(LIGHTGRAY); for i in 0..positions.len() { draw_texture(texture, positions[i].x, positions[i].y, GRAY); if positions[i].forward { positions[i].y += positions[i].speed } else { positions[i].y -= positions[i].speed } if positions[i].y + texture.height() > screen_height() { positions[i].y = screen_height() - texture.height(); positions[i].forward = false; } if positions[i].y < 0.0 { positions[i].y = 0.0; positions[i].forward = true; } } next_frame().await } }