Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update block.html - Alternating image #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions public/block.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -26,4 +22,4 @@
<body>
<p>Click on PacMan and the position will be sent to the server".</p>
<img id="PacMan" src='http://localhost:3000/pac?id=2' onclick="Run()" style="position:absolute">
</body>
</body>