satumaslahat / adu-suit

Proyek milik Kelompok 1 BYLEAD Digital BSI Batch 1 2024; untuk permainan: batu, gunting, kertas.
https://expo.dev/accounts/goranrango/projects/adu-suit/builds/c2684e48-2c50-45e7-898a-0aee6a9b33f0
0 stars 0 forks source link

Game Loops: newRound #1

Closed boexelfauyenra closed 1 month ago

boexelfauyenra commented 1 month ago

import React, { useState, useEffect } from 'react'; import { View, StyleSheet, Text, Animated, Easing } from 'react-native'; import { Button } from 'react-native-paper';

const App = () => { const [round, setRound] = useState(0); const [gameStarted, setGameStarted] = useState(false); const fadeAnim = new Animated.Value(0);

const startGame = () => { setGameStarted(true); setRound(1); fadeIn(); };

const newRound = () => { setRound(prevRound => prevRound + 1); fadeIn(); };

const fadeIn = () => { fadeAnim.setValue(0); Animated.timing(fadeAnim, { toValue: 1, duration: 500, easing: Easing.inOut(Easing.ease), useNativeDriver: true, }).start(); };

return (

{gameStarted ? ( Round {round} ) : ( )}

); };

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f4f4f4', }, roundContainer: { alignItems: 'center', }, roundText: { fontSize: 24, marginBottom: 20, }, button: { marginTop: 20, }, });

export default App;