About
Explore
Events & Classes
Support Us
Join
Sign In
Arpit Soni
View Project Page
Run
Fullscreen
Doughnut Clicker | Fork
HTML
CSS
JS
<!-- Comment with your score! --> <!DOCTYPE HTML> <html> <head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> </head> <body> <a class="open-modal" href="#modal">Instructions</a> <p>Clicks: <span>0</span></p> <p>Level: <span>1</span></p> <div onclick="resetClicks()" class="reset">reset</div> <br> <div onclick="clicked()" class="donut"> <div class="donut-icing"></div> </div> <div id="modal" class="modal"> <div class="modal-dialog"> <div class="modal-content"> <header class="container"> <a href="#" class="closebtn">×</a> <h2>Instructions</h2> </header> <div class="container"> <p>Click the donut to earn clicks and level up.</p> <p>To get to level 2 you need to earn: 100 clicks</p> <p>To get to level 3 you need to earn: 500 clicks</p> </div> </div> </div> </div> </body> </html>
body { justify-content: center; align-items: center; font-family: "montserrat", arial; user-select: none; } .donut { border: 80px #f5ff70 solid; width: 200px; height: 200px; cursor: pointer; border-radius: 50%; justify-content: center; align-items: center; display: block; margin: auto; } .donut-icing { width: 100px; height: 100px; border-radius: 50%; margin: auto; position: relative; left: -40px; top: -40px; display: block; border: 90px #ff9efa solid; } .reset { color: red; border: 10px solid red; text-transform: uppercase; display: block; width: 54px; margin: auto; padding: 5px; border-radius: 5px; cursor: pointer; } p { text-align: center; } @keyframes example { from {top:-100px;opacity: 0;} to {top:0px;opacity:1;} } .modal { display: none; position: fixed; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0.4); } .modal:target { display: table; position: absolute; } .modal-dialog { display: table-cell; vertical-align: middle; } .modal-dialog .modal-content { margin: auto; background-color: #f3f3f3; position: relative; padding: 0; outline: 0; border: 1px #777 solid; text-align: justify; width: 80%; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); -webkit-animation-name: example; -webkit-animation-duration: 0.5s; animation-name: example; animation-duration: 0.5s; } .closebtn { text-decoration: none; float: right; font-size: 35px; font-weight: bold; color: #fff; } .closebtn:hover, .closebtn:focus { color: #000; text-decoration: none; cursor: pointer; } .container { padding: 2px 16px; } header { background-color: #5cb85c; font-size: 25px; color: white; } .open-modal { color: white; background-color: green; text-decoration: none; padding: 5px; display: block; width: 81px; margin: auto; }
var donut_icing = document.querySelector(".donut-icing"); var para1 = document.getElementsByTagName("span")[0]; var para2 = document.getElementsByTagName("span")[1]; var mode1 = "#ff9efa"; var mode2 = "#ffd6fd"; var mode3 = "#b433ff"; var score = 0; var level = 1; var click = new Audio('https://justcodaborate.com/project_images/click.wav'); function resetClicks() { score = 0; level = 1; donut_icing.style.border = "90px solid "+mode1; para1.innerHTML = "0"; para2.innerHTML = "1"; } function clicked() { score++; click.play(); para1.innerHTML = score; if(level==3 && score==500) { donut_icing.style.border = "90px solid "+mode3; para1.innerHTML = score; para2.innerHTML = level; } else if(level==3 && score>500) { donut_icing.style.border = "90px solid "+mode3; para1.innerHTML = score; para2.innerHTML = level; } else if(level==2 && score>=100) { donut_icing.style.border = "90px solid "+mode2; para1.innerHTML = score; para2.innerHTML = level; level++; } else if(level==1 && score<100) { donut_icing.style.border = "90px solid "+mode1; para1.innerHTML = score; para2.innerHTML = level; level++; } else { score++; click.play(); para1.innerHTML = score; } }