Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var d;
- var uRx;
- var uRy;
- var len;
- function lepakol(pSzo, pRx, pRy) {
- if (len===0) { return true; }
- if (pRx<0 || pRy>=height || pRy<0 || pRx>=width || $('mxTable').rows[pRy].cells[pRx].innerHTML != ' ') {
- return false;
- }
- $('mxTable').rows[pRy].cells[pRx].innerHTML = szavak[pSzo].charAt(len-1);
- len--;
- if (len===0) { return true; }
- console.log(pRx + ' , ' + pRy);
- uRy = pRy;
- uRx = pRx;
- var i = 0;
- do {
- if (i == 0) {
- d = Math.floor(Math.random() * 4);
- } else {
- d = (d+1) % 4;
- }
- switch (d) {
- case 0:
- uRy = pRy;
- uRx = pRx-1;
- break;
- case 1:
- uRy = pRy;
- uRx = pRx+1;
- break;
- case 2:
- uRy = pRy-1;
- uRx = pRx;
- break;
- case 3:
- uRy = pRy+1;
- uRx = pRx;
- break;
- }
- i++;
- } while (i <= 4 && !lepakol(pSzo, uRx, uRy));
- if (i == 4) {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement