@@ -5,8 +5,10 @@ function App() {
5
5
//app component
6
6
const [ points , setPoints ] = useState ( 0 ) ; //set initial points to 0
7
7
const [ pointsPerSecond , setPointsPerSecond ] = useState ( 0 ) ;
8
+ const [ autoClickers , setAutoClickers ] = useState ( 0 ) ; //set auto clickers to 0
8
9
const [ clicks , setClicks ] = useState ( 0 ) ; //set initial clicks pressed to 0
9
10
const [ clickMultiplier , setClickMultiplier ] = useState ( 1 ) ;
11
+ const [ clickers , setClickers ] = useState ( 1 ) ; //set clickers to 1
10
12
const [ seconds , setSeconds ] = useState ( 0 ) ; //set initial seconds played to 0
11
13
useEffect ( ( ) => {
12
14
const interval = setInterval ( ( ) => {
@@ -28,23 +30,33 @@ function App() {
28
30
return false ;
29
31
}
30
32
}
33
+ function updateClickers ( ) {
34
+ //update click multiplier for clickers
35
+ setClickMultiplier ( clickers ) ; //set click multiplier
36
+ }
37
+ function updateAutoClickers ( ) {
38
+ //update points per second for autoclickers
39
+ setPointsPerSecond ( autoClickers ) ; //set points per second
40
+ }
31
41
function addPointsFromClick ( ) {
32
42
//add points from clicking a button
33
43
setPoints ( points + clickMultiplier ) ; //increase points by 1 when button clicked
34
44
setClicks ( clicks + 1 ) ; //increase clicks made by 1
35
45
}
36
46
function upgradeClicker ( ) {
37
47
//upgrade clicker (points per click)
38
- if ( checkPointsForUpgrade ( points , 10 * Math . pow ( 2 , clickMultiplier - 1 ) ) ) {
39
- setPoints ( points - 10 * Math . pow ( 2 , clickMultiplier - 1 ) ) ; //spend points
40
- setClickMultiplier ( clickMultiplier + 1 ) ; //increase click multiplier by 1
48
+ if ( checkPointsForUpgrade ( points , 10 * Math . pow ( 2 , clickers - 1 ) ) ) {
49
+ setPoints ( points - 10 * Math . pow ( 2 , clickers - 1 ) ) ; //spend points
50
+ setClickers ( clickers + 1 ) ; //increase clickers by 1
51
+ updateClickers ( ) ;
41
52
}
42
53
}
43
54
function upgradePointsPerSecond ( ) {
44
55
//upgrade points per second
45
56
if ( checkPointsForUpgrade ( points , 10 * Math . pow ( 2 , pointsPerSecond ) ) ) {
46
57
setPoints ( points - 10 * Math . pow ( 2 , pointsPerSecond ) ) ;
47
- setPointsPerSecond ( pointsPerSecond + 1 ) ; //increase points per second
58
+ setAutoClickers ( autoClickers + 1 ) ; //increase autoclickers by 1
59
+ updateAutoClickers ( ) ;
48
60
}
49
61
}
50
62
return (
@@ -62,18 +74,17 @@ function App() {
62
74
</ p >
63
75
{ /*increase points from clicking a button*/ }
64
76
< button onClick = { ( ) => addPointsFromClick ( ) } > Click to Add Points</ button >
77
+ < br />
65
78
{ /*upgrade clicker (points per click)*/ }
66
79
< button onClick = { ( ) => upgradeClicker ( ) } >
67
80
Upgrade Clicker (Points Per Click)
68
- < br />
69
- < CostDisplay cost = { 10 * Math . pow ( 2 , clickMultiplier - 1 ) } />
70
81
</ button >
82
+ < CostDisplay cost = { 10 * Math . pow ( 2 , clickers - 1 ) } />
71
83
{ /*upgrade points per second*/ }
72
84
< button onClick = { ( ) => upgradePointsPerSecond ( ) } >
73
85
Upgrade Points Per Second
74
- < br />
75
- < CostDisplay cost = { 10 * Math . pow ( 2 , pointsPerSecond ) } />
76
86
</ button >
87
+ < CostDisplay cost = { 10 * Math . pow ( 2 , autoClickers ) } />
77
88
</ div >
78
89
) ;
79
90
}
0 commit comments