aboutsummaryrefslogtreecommitdiff
path: root/pixel-client/tools/src/bin/bunnymark.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-29 23:56:14 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-30 01:19:09 +0200
commit727752b87bbe7146adb0f9e9e27d6e64b785ec2f (patch)
treeec51a98bb0f3334e66690484db497709d9d48eb4 /pixel-client/tools/src/bin/bunnymark.rs
parentbd52f4617d04d9b3cda279d48fc75d5a067101fe (diff)
downloadhurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar
hurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar.bz2
hurrycurry-727752b87bbe7146adb0f9e9e27d6e64b785ec2f.tar.zst
Remove pixel client
Diffstat (limited to 'pixel-client/tools/src/bin/bunnymark.rs')
-rw-r--r--pixel-client/tools/src/bin/bunnymark.rs106
1 files changed, 0 insertions, 106 deletions
diff --git a/pixel-client/tools/src/bin/bunnymark.rs b/pixel-client/tools/src/bin/bunnymark.rs
deleted file mode 100644
index a7ef412d..00000000
--- a/pixel-client/tools/src/bin/bunnymark.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Hurry Curry! - a game about cooking
- Copyright (C) 2025 Hurry Curry! Contributors
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, version 3 of the License only.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-*/
-use sdl2::{
- event::Event,
- image::{InitFlag, LoadTexture},
- keyboard::Keycode,
- pixels::Color,
- rect::Rect,
-};
-use std::time::Instant;
-
-const WIDTH: i32 = 1920;
-const HEIGHT: i32 = 1080;
-
-pub fn main() {
- let amount = std::env::args().nth(1).unwrap().parse().unwrap();
-
- let sdl_context = sdl2::init().unwrap();
- 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! Bunnymark", WIDTH as u32, HEIGHT as u32)
- .position_centered()
- .build()
- .map_err(|e| e.to_string())
- .unwrap();
-
- let mut canvas = window
- .into_canvas()
- .accelerated()
- .build()
- .map_err(|e| e.to_string())
- .unwrap();
- let texture_creator = canvas.texture_creator();
- let texture = texture_creator
- .load_texture("client/icons/main.png")
- .unwrap();
-
- 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.0 = r % WIDTH;
- r = xorshift(r);
- pos.1 = r % HEIGHT;
- r = xorshift(r);
- vel.0 = r % 7 - 3;
- r = xorshift(r);
- vel.1 = r % 7 - 3;
- }
-
- let mut last = Instant::now();
- 'mainloop: loop {
- canvas.set_draw_color(Color::BLACK);
- canvas.clear();
- for (pos, vel) in &mut bunnies {
- pos.0 += vel.0;
- pos.1 += vel.1;
- if pos.0 < 0 || pos.0 > WIDTH {
- vel.0 *= -1
- }
- if pos.1 < 0 || pos.1 > HEIGHT {
- vel.1 *= -1
- }
- canvas
- .copy(&texture, None, Some(Rect::new(pos.0, pos.1, 30, 30)))
- .unwrap();
- }
- canvas.present();
-
- for event in sdl_context.event_pump().unwrap().poll_iter() {
- match event {
- Event::Quit { .. }
- | Event::KeyDown {
- keycode: Option::Some(Keycode::Escape),
- ..
- } => break 'mainloop,
- _ => {}
- }
- }
- println!("frame time: {:?}", last.elapsed());
- last = Instant::now();
- }
-}
-
-fn xorshift(mut x: i32) -> i32 {
- x ^= x << 13;
- x ^= x >> 17;
- x ^= x << 5;
- x
-}