Created
March 17, 2024 19:43
-
-
Save angelcaru/62ee53eaf46a2ad8cba3237bd45703a4 to your computer and use it in GitHub Desktop.
"""Cookie clicker""" in 11 lines of code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="canvas" width="800" height="800"></canvas> | |
<script src="main.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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