I am making a snake game but when I try and instantiate my snake object I get "Uncaught TypeError: undefined is not a function".
function draw(){
var canvas = document.getElementById("canvas");
    if (canvas.getContext){
        var ctx = canvas.getContext('2d');
}
drawSnake();    
}
This is where I instantiate the snake object and draw it and where i get the error more specifically line 13.
function drawSnake(){
    var Snake = new Snake(250,250,-1,0);
    Snake.create();
    ctx.fillStyle = "white";
    for(i=Snake.snakeBlock.length(); i>=0;i--){
        var s = Snake.snakeBlock[i].block;
        ctx.fillRect(s.xPos,s.xPos,s.height,s.width);
    }
}    
function Block(x,y,w,h){
    var xPos = x;
    var yPos = y;
    var width = w;
    var height = h;
}
This is where I define the snake object yet I still get an error.
function Snake(x,y,dY,dX){
    var snakeBlock = [];
    var length = 20;
    var xPos = x;
    var yPos = y;
    var dirX = dX;
    var dirX = dY;
    Snake.prototype.create = function(){
        for (var i = 0; i <= length; i++) {
        snakeBlock.push(new Block((xPos-(i*10))*dirX, (yPos-(i*10))*dirY,10,10));
    };
}
}
Is there something that I am ignoring in the creation of objects as I can't figure out what is wrong with the code.
 
     
     
    