Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 18
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 18
22_23-J 18
Commits
aa46d8d4
Commit
aa46d8d4
authored
Apr 20, 2023
by
Lelkada L L P S M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
game changes
parent
3cfe670f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6616 additions
and
5785 deletions
+6616
-5785
App/Frontend/screens/FlipCardGameScreen.js
App/Frontend/screens/FlipCardGameScreen.js
+57
-11
App/Frontend/screens/WordGenerationScreen.js
App/Frontend/screens/WordGenerationScreen.js
+3
-2
App/Frontend/screens/game_chime.m4a
App/Frontend/screens/game_chime.m4a
+0
-0
App/Frontend/yarn.lock
App/Frontend/yarn.lock
+6556
-5772
No files found.
App/Frontend/screens/FlipCardGameScreen.js
View file @
aa46d8d4
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
{
StyleSheet
,
View
,
TouchableOpacity
,
Image
,
Text
,
Modal
,
Button
}
from
'
react-native
'
;
import
{
Audio
}
from
'
expo-av
'
;
import
{
Asset
}
from
'
expo-asset
'
;
const
Card
=
({
image
,
audio
,
onFlip
,
gameOver
,
correct
,
soundRef
})
=>
{
const
[
isFlipped
,
setIsFlipped
]
=
useState
(
false
);
...
...
@@ -48,12 +47,37 @@ const Card = ({ image, audio, onFlip, gameOver, correct, soundRef }) => {
);
};
const
MessageBox
=
({
visible
,
onClose
})
=>
{
const
MessageBox
=
({
visible
,
onClose
,
onReset
})
=>
{
const
[
messageBoxVisible
,
setMessageBoxVisible
]
=
useState
(
visible
);
const
sound
=
React
.
useRef
(
new
Audio
.
Sound
());
useEffect
(()
=>
{
setMessageBoxVisible
(
visible
);
if
(
visible
)
{
(
async
()
=>
{
try
{
await
sound
.
current
.
unloadAsync
();
const
{
sound
:
newSound
}
=
await
Audio
.
Sound
.
createAsync
(
{
uri
:
'
https://fyp-word-audio.s3.us-east-2.amazonaws.com/game_chime.m4a
'
},
// Replace with your audio file URL
{
shouldPlay
:
true
},
);
sound
.
current
=
newSound
;
}
catch
(
error
)
{
console
.
log
(
'
Error playing audio:
'
,
error
);
}
})();
setTimeout
(()
=>
{
setMessageBoxVisible
(
false
);
onReset
();
},
4000
);
}
},
[
visible
]);
return
(
<
Modal
animationType
=
"
slide
"
transparent
=
{
true
}
visible
=
{
v
isible
}
>
<
Modal
animationType
=
"
slide
"
transparent
=
{
true
}
visible
=
{
messageBoxV
isible
}
>
<
View
style
=
{
styles
.
modalContainer
}
>
<
View
style
=
{
styles
.
modalContent
}
>
<
Text
style
=
{
styles
.
modalText
}
>
Game
Over
<
/Text
>
<
Text
style
=
{
styles
.
modalText
}
>
Awesome
!!
<
/Text
>
<
Button
title
=
"
Close
"
onPress
=
{
onClose
}
/
>
<
/View
>
<
/View
>
...
...
@@ -61,10 +85,11 @@ const MessageBox = ({ visible, onClose }) => {
);
};
export
default
function
FlipCardGame
(
{
navigation
}
)
{
export
default
function
FlipCardGame
()
{
const
[
gameOver
,
setGameOver
]
=
useState
(
false
);
const
[
imagesData
,
setImagesData
]
=
useState
([]);
const
soundRef
=
React
.
useRef
(
new
Audio
.
Sound
());
const
mainImage
=
imagesData
.
find
((
img
)
=>
img
.
isMainImage
);
useEffect
(()
=>
{
const
unloadAudio
=
async
()
=>
{
...
...
@@ -76,12 +101,14 @@ export default function FlipCardGame({ navigation }) {
};
},
[]);
useEffect
(()
=>
{
fetchImagesData
();
},
[]);
const
mainImage
=
imagesData
.
find
((
img
)
=>
img
.
isMainImage
);
const
resetGame
=
()
=>
{
setGameOver
(
false
);
fetchImagesData
();
};
const
fetchImagesData
=
async
()
=>
{
try
{
...
...
@@ -107,7 +134,6 @@ export default function FlipCardGame({ navigation }) {
const
handleCardFlip
=
(
flippedImage
)
=>
{
if
(
flippedImage
.
uri
===
mainImage
.
image_link
)
{
setGameOver
(
true
);
navigation
.
navigate
(
'
ContentGeneration
'
);
}
};
...
...
@@ -129,9 +155,16 @@ export default function FlipCardGame({ navigation }) {
/
>
))}
<
/View
>
<
MessageBox
style
=
{
styles
.
messagebox
}
visible
=
{
gameOver
}
onClose
=
{()
=>
{
setGameOver
(
false
);
}}
onReset
=
{
resetGame
}
/
>
<
/View
>
);
}
const
styles
=
StyleSheet
.
create
({
...
...
@@ -143,7 +176,7 @@ const styles = StyleSheet.create({
},
mainImage
:
{
width
:
'
80%
'
,
height
:
'
40
%
'
,
height
:
'
35
%
'
,
resizeMode
:
'
cover
'
,
},
cardsContainer
:
{
...
...
@@ -169,4 +202,17 @@ const styles = StyleSheet.create({
borderColor
:
'
green
'
,
borderWidth
:
5
,
},
modalContainer
:
{
flex
:
1
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
,
margin
:
150
,
},
modalContent
:
{
backgroundColor
:
'
#fff
'
,
padding
:
20
,
borderRadius
:
10
,
alignItems
:
'
center
'
,
},
});
App/Frontend/screens/WordGenerationScreen.js
View file @
aa46d8d4
import
React
,
{
useState
,
useRef
,
useEffect
}
from
"
react
"
;
import
React
,
{
useState
,
useRef
,
useEffect
,
useFocusEffect
}
from
"
react
"
;
import
{
View
,
Text
,
...
...
@@ -9,6 +9,7 @@ import {
Dimensions
,
ImageBackground
,
}
from
"
react-native
"
;
import
{
Audio
}
from
"
expo-av
"
;
import
{
MaterialIcons
}
from
'
@expo/vector-icons
'
;
import
{
Ionicons
}
from
'
@expo/vector-icons
'
;
...
...
@@ -36,7 +37,7 @@ export default function ContentGenerationScreen({ navigation }) {
const
soundRef
=
useRef
(
new
Audio
.
Sound
());
//console.log(cards);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
loadCards
=
async
()
=>
{
const
fetchedCards
=
await
fetchCards
();
setCards
(
fetchedCards
);
...
...
App/Frontend/screens/game_chime.m4a
0 → 100644
View file @
aa46d8d4
File added
App/Frontend/yarn.lock
View file @
aa46d8d4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment