I have a strange behavior with a simple function in javascript. I write in a matrix, but when I read it again, I can't see the changes. Can someone please explain me why? Here is the code:
this.map = [
'## ### ##',
'# # #',
'# # . # #',
'# ## # #',
'## # #',
'#*# ## ##',
' ## ',
'#########'
];
this.check_collision = function ( x, y ) {
var l = Math.floor ( y / this.tile_size );
var c = Math.floor ( x / this.tile_size );
if ( this.map[ l ] != undefined ) {
if ( this.map[ l ][ c ] != undefined ) {
if ( this.map[ l ][ c ] == '#' ) {
return true;
}
else if ( this.map[ l ][ c ] == '.' || this.map[ l ][ c ] == '*' ) {
this.map[ l ][ c ] = ' ';
console.debug ( "'" + this.map[ l ][ c ] + "'" );
}
}
}
return false;
};
The console.debug() prints '.' or '*', but I write the char ' ' the line above