HTML Canvas doesn't have a collision detector sistem. So, you must describes the walls in JavaScript so you draw them from this description. Next, you have to process the position every time the player moves.
I.e.
wall = []
wall[0] = {"p1":[0,0],"p2":[0,100]} // the P1 and P2 points of line of wall
...
After, you must determine players corners. For each corner, you may detect if is in wall.
function line_detect(wall,point){ // based on line formula of analytic geometry
var a = (wall.p1[0] - wall.p2[0]) / (wall.p1[1] - wall.p2[1]);
var b = wall.p1[1];
var y = a*point[0]+b;
if(y == point[1])
return 0;
else if(y > point[1])
return 1;
else return -1;
}
function range_detect(wall,point){
if(point[0] > wall.p1[0]
&& point[0] > wall.p2[0])
return 0;
if(point[0] < wall.p1[0]
&& point[0] < wall.p2[0])
return 0;
if(point[1] > wall.p1[1]
&& point[1] > wall.p2[1])
return 0;
if(point[1] < wall.p1[1]
&& point[1] > wall.p2[1])
return 0;
return 1;
}
With this functions you can determine if a point is:
* after line or before line
* in line limits or out line limits
Now, you must have to check for each corner, and if all out of range, so no colision is detect. Is is in the range and all in the same side, no collision is detect too. But if some corners are after line and another before, you have a colision.