diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-16 16:28:59 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-16 16:28:59 +0200 |
commit | 12a4da7b1ecf4b751a749d49df0696ae5df92ba5 (patch) | |
tree | 28212775f51bf13751a97fb3371794d57aee6c07 | |
parent | 3c16211e2a2f0c3dbe741da20c8499e8e6a15f85 (diff) | |
download | hurrycurry-12a4da7b1ecf4b751a749d49df0696ae5df92ba5.tar hurrycurry-12a4da7b1ecf4b751a749d49df0696ae5df92ba5.tar.bz2 hurrycurry-12a4da7b1ecf4b751a749d49df0696ae5df92ba5.tar.zst |
move bunnymark
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | light-client/tools/Cargo.toml | 1 | ||||
-rw-r--r-- | light-client/tools/src/bin/bunnymark.rs (renamed from light-client/src/bin/bunnymark.rs) | 26 |
3 files changed, 15 insertions, 13 deletions
@@ -1983,6 +1983,7 @@ dependencies = [ "env_logger", "image", "log", + "sdl2", ] [[package]] diff --git a/light-client/tools/Cargo.toml b/light-client/tools/Cargo.toml index 2a1dacb9..f3075594 100644 --- a/light-client/tools/Cargo.toml +++ b/light-client/tools/Cargo.toml @@ -9,3 +9,4 @@ anyhow = "1.0.86" log = "0.4.22" env_logger = "0.11.3" clap = { version = "4.5.9", features = ["derive"] } +sdl2 = "0.37.0" diff --git a/light-client/src/bin/bunnymark.rs b/light-client/tools/src/bin/bunnymark.rs index 12c18d66..f59fecff 100644 --- a/light-client/src/bin/bunnymark.rs +++ b/light-client/tools/src/bin/bunnymark.rs @@ -15,7 +15,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -use hurrycurry_protocol::glam::IVec2; use sdl2::{ event::Event, image::{InitFlag, LoadTexture}, @@ -35,7 +34,7 @@ pub fn main() { let video_subsystem = sdl_context.video().unwrap(); let _image_context = sdl2::image::init(InitFlag::WEBP | InitFlag::PNG).unwrap(); let window = video_subsystem - .window("Hurry Curry! Light Client", WIDTH as u32, HEIGHT as u32) + .window("Hurry Curry! Bunnymark", WIDTH as u32, HEIGHT as u32) .position_centered() .build() .map_err(|e| e.to_string()) @@ -50,17 +49,17 @@ pub fn main() { let texture_creator = canvas.texture_creator(); let texture = texture_creator.load_texture("client/icon.png").unwrap(); - let mut bunnies = vec![(IVec2::ZERO, IVec2::ONE); amount]; + let mut bunnies = vec![((0, 0), (0, 0)); amount]; for (i, (pos, vel)) in bunnies.iter_mut().enumerate() { let mut r = xorshift(i as i32); - pos.x = r % WIDTH; + pos.0 = r % WIDTH; r = xorshift(r); - pos.y = r % HEIGHT; + pos.1 = r % HEIGHT; r = xorshift(r); - vel.x = r % 7 - 3; + vel.0 = r % 7 - 3; r = xorshift(r); - vel.y = r % 7 - 3; + vel.1 = r % 7 - 3; } let mut last = Instant::now(); @@ -68,15 +67,16 @@ pub fn main() { canvas.set_draw_color(Color::BLACK); canvas.clear(); for (pos, vel) in &mut bunnies { - *pos += *vel; - if pos.x < 0 || pos.x > WIDTH { - vel.x *= -1 + pos.0 += vel.0; + pos.1 += vel.1; + if pos.0 < 0 || pos.0 > WIDTH { + vel.0 *= -1 } - if pos.y < 0 || pos.y > HEIGHT { - vel.y *= -1 + if pos.1 < 0 || pos.1 > HEIGHT { + vel.1 *= -1 } canvas - .copy(&texture, None, Some(Rect::new(pos.x, pos.y, 30, 30))) + .copy(&texture, None, Some(Rect::new(pos.0, pos.1, 30, 30))) .unwrap(); } canvas.present(); |