moved set draw color out of loop

This commit is contained in:
2026-02-06 03:42:29 -06:00
parent 67323339cc
commit ede4519891

View File

@@ -55,11 +55,11 @@ fn draw(canvas: &mut sdl2::render::WindowCanvas, cols: &i32, rows: &i32, boxsize
canvas.set_draw_color(Color::RGB(0,0,0)); canvas.set_draw_color(Color::RGB(0,0,0));
canvas.clear(); canvas.clear();
canvas.set_draw_color(Color::RGB(150,50,255));
for (i, vec) in grid.iter().enumerate(){ for (i, vec) in grid.iter().enumerate(){
for (j, num) in vec.iter().enumerate(){ for (j, num) in vec.iter().enumerate(){
if *num==1 { if *num==1 {
//putRectRGB(renderer,i*boxsize,j*boxsize,boxsize-1,150,50,255); //putRectRGB(renderer,i*boxsize,j*boxsize,boxsize-1,150,50,255);
canvas.set_draw_color(Color::RGB(150,50,255));
let x: i32= i as i32 * *boxsize; let x: i32= i as i32 * *boxsize;
let y: i32= j as i32 * *boxsize; let y: i32= j as i32 * *boxsize;
canvas.fill_rect(Rect::new(x, y, *boxsize as u32 -1, *boxsize as u32-1)); canvas.fill_rect(Rect::new(x, y, *boxsize as u32 -1, *boxsize as u32-1));
@@ -123,6 +123,7 @@ fn main() {
} }
// The rest of the game loop goes here... // The rest of the game loop goes here...
//uncomment for framerate limit
//::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60)); //::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
} }
} }