File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ function App() {
77 const [ pointsPerSecond , setPointsPerSecond ] = useState ( 0 ) ;
88 const [ clicks , setClicks ] = useState ( 0 ) ; //set initial clicks pressed to 0
99 const [ clickMultiplier , setClickMultiplier ] = useState ( 1 ) ;
10+ const [ seconds , setSeconds ] = useState ( 0 ) ; //set initial seconds played to 0
1011 useEffect ( ( ) => {
1112 const interval = setInterval ( ( ) => {
1213 //increase points every second
13- setPoints ( points + pointsPerSecond ) ;
14+ setPoints ( points + pointsPerSecond ) ; //increase points by points per second
15+ setSeconds ( seconds + 1 ) ; //add 1 second
1416 } , 1000 ) ;
1517 return ( ) => {
1618 clearInterval ( interval ) ; //clear interval when component unmounts
@@ -29,7 +31,7 @@ function App() {
2931 function addPointsFromClick ( ) {
3032 //add points from clicking a button
3133 setPoints ( points + clickMultiplier ) ; //increase points by 1 when button clicked
32- setClicks ( clicks + clickMultiplier ) ; //increase clicks made by 1
34+ setClicks ( clicks + 1 ) ; //increase clicks made by 1
3335 }
3436 function upgradeClicker ( ) {
3537 //upgrade clicker (points per click)
You can’t perform that action at this time.
0 commit comments