i was wondering how i would move my picture(the green block) down the already created blocks one block at a time, i would like to do it someway without using setinterval like through a for loop or an if statement to increment x or something, any suggestions? here is a link to a jsfiddle http://jsfiddle.net/ueo30Lg0/
var rows = 20;
var cols = 10;
var size = 32;
function drawBoard(){
ctx.fillStyle="#D3D3D3";
ctx.fillRect( 0,55,320, 400);
var colors = ['#FFFFFF','#000000'];
var squares = colors;
var square = 0;
canvas = document.getElementById('gameCanvas');
canvas_width = canvas.width;
canvas_height = canvas.height;
for(var row=0; row<rows; row++) {
for(var col=0; col<cols; col++) {
var x = col*size;
var y = row*size;
ctx.fillStyle = squares[square++%colors.length];
ctx.fillRect(x,y,size,size);
}
square += colors.length-1;
}
}
and here is where the block i want to move is
var logo2 = new Image();
logo2.src = 'http://hdwallphotos.com/wp-content/uploads/2014/02/Green-Background-Image-CSS-Wallpaper.png'
function blocks(){
logo2.onload = function(){
canvas = document.getElementById('gameCanvas');
ctx = canvas.getContext('2d');
for(var row=0; row<rows; row++) {
for(var col=0; col<cols; col++) {
var x = col;
var y = row;
ctx.drawImage(logo2, x,y,23,13);
}
}
};
}