Skip to content

Instantly share code, notes, and snippets.

@JustLinuxUser
Created October 1, 2025 13:39
Show Gist options
  • Select an option

  • Save JustLinuxUser/beb6bc0c2d59efa572e652630a71fc4a to your computer and use it in GitHub Desktop.

Select an option

Save JustLinuxUser/beb6bc0c2d59efa572e652630a71fc4a to your computer and use it in GitHub Desktop.
use buffer_graphics_lib::prelude::*;
use minifb::{Key, Window, WindowOptions};
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
fn main() {
// window shit
let window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
);
let mut window = window.unwrap_or_else(|e| {
panic!("{}", e);
});
// Limit to max ~60 fps update rate
window.set_target_fps(60);
// initialize the buffer
let mut buffer = Graphics::create_buffer_u32(WIDTH, HEIGHT); // ARGB
let mut pos = 0;
while window.is_open() && !window.is_key_down(Key::Escape) {
// this shit is stupid, having to recreate this on every frame is dumb, but it's cheap so
// who cares, and the library could have easily avoided this
let mut graphics = Graphics::new_u32_argb(&mut buffer, WIDTH, HEIGHT).unwrap();
//reset each frame
graphics.clear(BLACK);
pos += 10;
if pos >= WIDTH {
pos = 0;
}
graphics.draw_circle(Circle::new((pos, HEIGHT / 2), 10), DrawType::Fill(GREEN));
if let Some(mouse_pos) = window.get_mouse_pos(minifb::MouseMode::Pass) {
graphics.draw_circle(Circle::new(mouse_pos, 10), DrawType::Fill(GREEN));
}
window.update_with_buffer(&buffer, WIDTH, HEIGHT).unwrap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment