|
|
@ -21,7 +21,7 @@ function Game(props){ |
|
|
|
const [timerState, setTimerState] = useState(0); |
|
|
|
const localTimer = useRef(null); |
|
|
|
const startTime = useRef(0); |
|
|
|
const score = useRef(0); |
|
|
|
const answers = useRef(0); |
|
|
|
const [scrollOrigin, setScrollOrigin] = useState(0); |
|
|
|
const scrollDestination = useRef(Metrics.animated.gameScrollInterval); |
|
|
|
const [headerText, setHeaderText] = useState('Ready?'); |
|
|
@ -80,7 +80,7 @@ function Game(props){ |
|
|
|
function selectAnswer(pairIndex, correct){ |
|
|
|
if (pairIndex === challengeState.current){ |
|
|
|
if (correct) { |
|
|
|
score.current = score.current + 1; |
|
|
|
answers.current = answers.current + 1; |
|
|
|
} |
|
|
|
|
|
|
|
let newOrigin = scrollDestination.current; |
|
|
@ -102,9 +102,7 @@ function Game(props){ |
|
|
|
setHeaderColor(styles.darkGreen); |
|
|
|
setHeaderText(finalTime + ' s'); |
|
|
|
setTimerState(4); |
|
|
|
setTimeout(() => { |
|
|
|
dispatch(squareFinished(score.current, finalTime)); |
|
|
|
}, 3000); |
|
|
|
dispatch(squareFinished(answers.current, finalTime)); |
|
|
|
} |
|
|
|
|
|
|
|
function generateSquare(pairIndex){ |
|
|
@ -194,7 +192,7 @@ function Game(props){ |
|
|
|
</View> |
|
|
|
<View style={[styles.timerView, styles.dark, styles.centeredJustify]}> |
|
|
|
<Text style={[styles.lightText, styles.headerTitleFont, styles.centeredText]}> |
|
|
|
{score.current + ' / ' + squareChallenge.current.length} |
|
|
|
{answers.current + ' / ' + squareChallenge.current.length} |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</SafeAreaView> |
|
|
|