Spaces:
Sleeping
Sleeping
Commit
·
5a82009
1
Parent(s):
3e79ae9
Remove logs
Browse filesChange size & color
- index.html +3 -14
index.html
CHANGED
|
@@ -68,8 +68,7 @@
|
|
| 68 |
|
| 69 |
function resetTimer() {
|
| 70 |
clearTimeout(timer);
|
| 71 |
-
timer = setTimeout(decideWinner,
|
| 72 |
-
updateStatusText('Timer reset');
|
| 73 |
}
|
| 74 |
|
| 75 |
function decideWinner() {
|
|
@@ -80,12 +79,7 @@
|
|
| 80 |
|
| 81 |
// Clear all circles
|
| 82 |
circles = [winnerCircle];
|
| 83 |
-
winnerCircle.color = '
|
| 84 |
-
updateStatusText(`Winner decided: Circle ${winnerCircle.id}`);
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
function updateStatusText(text) {
|
| 88 |
-
statusText.textContent = text;
|
| 89 |
}
|
| 90 |
|
| 91 |
function draw() {
|
|
@@ -96,12 +90,11 @@
|
|
| 96 |
// Draw all circles
|
| 97 |
circles.forEach(circle => {
|
| 98 |
ctx.beginPath();
|
| 99 |
-
ctx.arc(circle.x, circle.y,
|
| 100 |
ctx.fillStyle = circle.color || '#fff';
|
| 101 |
ctx.fill();
|
| 102 |
ctx.closePath();
|
| 103 |
});
|
| 104 |
-
updateStatusText(`Draw: ${circles.length}`);
|
| 105 |
|
| 106 |
animationId = requestAnimationFrame(draw);
|
| 107 |
}
|
|
@@ -109,7 +102,6 @@
|
|
| 109 |
function addCircle(x, y, id) {
|
| 110 |
circles.push({ id, x, y, color: '#fff' });
|
| 111 |
resetTimer();
|
| 112 |
-
updateStatusText(`Circle added: ${id}`);
|
| 113 |
}
|
| 114 |
|
| 115 |
function updateCircle(id, x, y) {
|
|
@@ -117,14 +109,12 @@
|
|
| 117 |
if (circle) {
|
| 118 |
circle.x = x;
|
| 119 |
circle.y = y;
|
| 120 |
-
updateStatusText(`Circle updated: ${id}`);
|
| 121 |
}
|
| 122 |
}
|
| 123 |
|
| 124 |
function removeCircle(id) {
|
| 125 |
circles = circles.filter(c => c.id !== id);
|
| 126 |
resetTimer();
|
| 127 |
-
updateStatusText(`Circle removed: ${id}`);
|
| 128 |
}
|
| 129 |
|
| 130 |
canvas.addEventListener('touchstart', (event) => {
|
|
@@ -156,7 +146,6 @@
|
|
| 156 |
|
| 157 |
// Start the drawing loop
|
| 158 |
draw();
|
| 159 |
-
updateStatusText('Drawing loop started');
|
| 160 |
});
|
| 161 |
</script>
|
| 162 |
</body>
|
|
|
|
| 68 |
|
| 69 |
function resetTimer() {
|
| 70 |
clearTimeout(timer);
|
| 71 |
+
timer = setTimeout(decideWinner, 4000);
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
function decideWinner() {
|
|
|
|
| 79 |
|
| 80 |
// Clear all circles
|
| 81 |
circles = [winnerCircle];
|
| 82 |
+
winnerCircle.color = '#228B22';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
function draw() {
|
|
|
|
| 90 |
// Draw all circles
|
| 91 |
circles.forEach(circle => {
|
| 92 |
ctx.beginPath();
|
| 93 |
+
ctx.arc(circle.x, circle.y, 120, 0, Math.PI * 2); // Radius of 50
|
| 94 |
ctx.fillStyle = circle.color || '#fff';
|
| 95 |
ctx.fill();
|
| 96 |
ctx.closePath();
|
| 97 |
});
|
|
|
|
| 98 |
|
| 99 |
animationId = requestAnimationFrame(draw);
|
| 100 |
}
|
|
|
|
| 102 |
function addCircle(x, y, id) {
|
| 103 |
circles.push({ id, x, y, color: '#fff' });
|
| 104 |
resetTimer();
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
function updateCircle(id, x, y) {
|
|
|
|
| 109 |
if (circle) {
|
| 110 |
circle.x = x;
|
| 111 |
circle.y = y;
|
|
|
|
| 112 |
}
|
| 113 |
}
|
| 114 |
|
| 115 |
function removeCircle(id) {
|
| 116 |
circles = circles.filter(c => c.id !== id);
|
| 117 |
resetTimer();
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
canvas.addEventListener('touchstart', (event) => {
|
|
|
|
| 146 |
|
| 147 |
// Start the drawing loop
|
| 148 |
draw();
|
|
|
|
| 149 |
});
|
| 150 |
</script>
|
| 151 |
</body>
|