moved set draw color out of loop
This commit is contained in:
@@ -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.clear();
|
||||
|
||||
canvas.set_draw_color(Color::RGB(150,50,255));
|
||||
for (i, vec) in grid.iter().enumerate(){
|
||||
for (j, num) in vec.iter().enumerate(){
|
||||
if *num==1 {
|
||||
//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 y: i32= j as i32 * *boxsize;
|
||||
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...
|
||||
|
||||
//uncomment for framerate limit
|
||||
//::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user