use minifb::{Key, Window, WindowOptions};
use blitter::*;
const WIDTH: usize = 640;
const HEIGHT: usize = 480;
fn main() {
let mut pixels: Vec<u32> = vec!(0; WIDTH * HEIGHT);
let mut fb = Framebuffer {width: WIDTH, height: HEIGHT, pixels: &mut pixels};
let image: Vec<u32> = { vec![0xffffffff; 100] };
let mut bitmap = Bitmap {w: 10, h: 10, x: 0, y: 0, pixels: &image};
let mut window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));
while window.is_open() && !window.is_key_down(Key::Escape) {
move_square(&mut fb, &mut bitmap);
window
.update_with_buffer(&fb.pixels, WIDTH, HEIGHT)
.unwrap();
}
}
fn move_square(mut fb: &mut Framebuffer, mut bitmap: &mut Bitmap) {
fb.clear_area(640, 10, 0, 0, 0).unwrap();
bitmap.blit(&mut fb);
if bitmap.x < WIDTH as isize - 10 { bitmap.x = bitmap.x+3; }
}