jquery - Javascript - How to make sliding puzzle pieces slide rather than jump into place. -


'i'm working on 3x3 sliding-tile puzzle game using javascript.

currently working correctly, except make tiles slide position, rather jump place - current code doing.

this current code relates moving tiles:

document.getelementbyid('puzzle').onclick = function() {   if (distance(clickloc.x, clickloc.y, emptyloc.x, emptyloc.y) == 1) {     slidetile(emptyloc, clickloc);     drawtiles();  function slidetile(toloc, fromloc) {   if (!solved) {     boardparts[toloc.x][toloc.y].x = boardparts[fromloc.x][fromloc.y].x;     boardparts[toloc.x][toloc.y].y = boardparts[fromloc.x][fromloc.y].y;     boardparts[fromloc.x][fromloc.y].x = tilecount - 1;     boardparts[fromloc.x][fromloc.y].y = tilecount - 1;     toloc.x = fromloc.x;     toloc.y = fromloc.y;     checksolved();   } } 

the player needs click on tile next empty space, when this, tile clicked on moves empty space, , area tile becomes empty. i'm wondering changes need make make tile slide place, rather instantly jump it.

thank in advance!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -