diff --git a/public/block.html b/public/block.html index e7999c4..5a59760 100644 --- a/public/block.html +++ b/public/block.html @@ -11,12 +11,8 @@ img = document.getElementById("PacMan"); pos += 20; img.style.left = pos + "px"; - if (flag === 1) { - img.src = url + '/pac?id=' + flag; // use flag to choose image - flag = 2; - } else { - flag = 1; - } + flag = (pos % 40 === 20) ? 1 : 2; // alternate flag value beetwen 0 and 1 + img.src = url + '/pac?id=' + flag; // use flag to choose image // send position data to Server in url fetch(url + '/set?x=' + pos); } @@ -26,4 +22,4 @@

Click on PacMan and the position will be sent to the server".

- \ No newline at end of file +