Skip to content

Instantly share code, notes, and snippets.

@angelcaru
Created March 17, 2024 19:43
Show Gist options
  • Save angelcaru/62ee53eaf46a2ad8cba3237bd45703a4 to your computer and use it in GitHub Desktop.
Save angelcaru/62ee53eaf46a2ad8cba3237bd45703a4 to your computer and use it in GitHub Desktop.
"""Cookie clicker""" in 11 lines of code
<canvas id="canvas" width="800" height="800"></canvas>
<script src="main.js"></script>
let [ctx, score, timer] = [(canvas = document.querySelector("canvas")).getContext("2d"), 0, 0];
canvas.addEventListener("click", () => score++);
(function animate() {
ctx.fillStyle = "brown";
ctx.beginPath();
ctx.ellipse(400, 400, 100, 100, Math.PI / 4, 0, 2 * Math.PI);
ctx.fill();
console.log(`Score: ${score}\nTime: ${timer++}`);
requestAnimationFrame(animate)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment