Simple click-based web game with JS
Randomly displays bug and carrots in the field and if we click bug, game is over. If we click all the carrots in the field, we win.
- Work with Web API (setInterval,scroll)
- Try refactoring and practice JS modules
- Project based on Frontend 101 Online COurse from Dream Coding
from 2021.08.21 - 31.
I used..
- HTML
- CSS
- Javascript
- Replit
with Github.
-
- get coordinates of
field
element withgetBoundingCLientRect
method. getRandomArbitrary
function for generating random number.
- get coordinates of
-
setInterval
for displaying decreasing number with every seconds.clearInterval
for resetting timer in following cases.- number reaches to 0
- user clicks
bug
element - user clicks all of the
carrot
elements
-
- 1 js file (main.js)
- functions unsorted
- no use of class & instances
-
- 3 js file (main.js,field.js,popup.js)
- methods and properties are sorted in each modules
- instances are made from field and popup classes