I created a turn-based javascript game.For moving the players I use jQuery. I'm moving a sprite inside my game board which consists of 100 squares with board-0 ids to board-99. I'm moving my sprite from id to id. Everything works perfectly, but I can not prohibit certain id's to travel. All the boxes with a class "accesOn" are ok all those with the class "accesOff" should not be used. I managed to block the upward movement, if the top position to a "accesOff" class at the start of the game. The problem is that after my sprite never goes up again. Could you help me to make sure not to move on all the divs that have an "accesOff" class? Thanks
/*********RECUP. ID POS. TOP before move******** */
var nombreIdPos = maDivId.substr(6);
var posActuelleNombreId = parseInt(nombreIdPos);
var posDessusNombreId = posActuelleNombreId -= 10;
var $posDessusId = 'board-' + posDessusNombreId;
//******** MOVE
function main() {
var $nombreId = maDivId.substr(6);
var $posDiv1 = parseInt($nombreId);
var $currentPosId = maDivId; //TEST voir si besoin plus tard
var $largeur = ($('#contenu').width());
var $hauteur = ($('#contenu').height());
$(window).on('keydown', function (e) {
var touche = e.which;
switch (touche) {
case 38: //TOP
var $idDivDessus = $('#' + $posDessusId);
if ($idDivDessus.hasClass('accesOn')) { // this if is not good
$posX = '0%';
$posY = '100%';
var $newPosH = $posDiv1 -= 10;
var $newPos = $("#board-" + $newPosH);
$($newPos).css('background', $player1 + $posX + $posY);
$('.joueur1').css('background', "").removeClass('joueur1');
$($newPos).addClass('joueur1');
} //****FIN IF
} //FIN if 1er
break;
}); // FIN Event keydown
} //FIN main function
$(document).ready(main);