diff --git a/src/components/tutorials/MoveAround.jsx b/src/components/tutorials/MoveAround.jsx new file mode 100644 index 0000000..f57f7bf --- /dev/null +++ b/src/components/tutorials/MoveAround.jsx @@ -0,0 +1,48 @@ +import React from "react"; +import Lottie from "lottie-react"; +import { motion } from "framer-motion"; + +import animationDeplacement from "../../assets/animations/ecran-deplacement.json"; +import { useUser } from "../../hooks/useUser"; +import Loading from "../animations/Loading"; +export default function MoveAround({ setNextSlide }) { + const { screensTranslations } = useUser(); + + if (!screensTranslations || !screensTranslations.tutorial) return ; + const currentScreenTranslations = screensTranslations.tutorial; + + const animationParameters = { + initial: { x: "100%", opacity: 0 }, + animate: { x: "0%", opacity: 1 }, + exit: { x: "-100%", opacity: 0 }, + }; + return ( + +
+

{currentScreenTranslations.how_to_play}

+

{currentScreenTranslations.move_around}

+ +

{currentScreenTranslations.move_around_description}

+
+ +
+
+
+ +
+
+ ); +} diff --git a/src/components/tutorials/PointsAndTime.jsx b/src/components/tutorials/PointsAndTime.jsx new file mode 100644 index 0000000..1d508ab --- /dev/null +++ b/src/components/tutorials/PointsAndTime.jsx @@ -0,0 +1,58 @@ +import React from "react"; +import Lottie from "lottie-react"; +import { motion } from "framer-motion"; + +import animationPoints from "../../assets/animations/ecran-points.json"; +import { useGame } from "../../hooks/useGame"; +import { useUser } from "../../hooks/useUser"; +import Loading from "../animations/Loading"; + +export default function PointsAndTime({ setNextSlide, setPreviousSlide, startGame }) { + const { setHasCheckedTutorial, hasCheckedTutorial } = useGame(); + + const { screensTranslations } = useUser(); + + if (!screensTranslations || !screensTranslations.tutorial) return ; + const currentScreenTranslations = screensTranslations.tutorial; + + const animationParameters = { + initial: { x: "100%", opacity: 0 }, + animate: { x: "0%", opacity: 1 }, + exit: { x: "-100%", opacity: 0 }, + }; + + return ( + +
+

{currentScreenTranslations.how_to_play}

+

{currentScreenTranslations.points_and_time}

+ +

{currentScreenTranslations.points_and_time_description}

+
+ + +
+
+
+ +
+
+ ); +} diff --git a/src/components/tutorials/Tutorials.jsx b/src/components/tutorials/Tutorials.jsx new file mode 100644 index 0000000..c33ae96 --- /dev/null +++ b/src/components/tutorials/Tutorials.jsx @@ -0,0 +1,37 @@ +import React, { useEffect, useState } from "react"; +import Modal from "../ui/Modal.jsx"; +import { useGame } from "../../hooks/useGame.jsx"; +import MoveAround from "./MoveAround.jsx"; +import PointsAndTime from "./PointsAndTime.jsx"; +import Walkthrough from "./Walkthrough.jsx"; + +export default function Tutorials() { + const { hasCheckedTutorial, setHasCheckedTutorial, setIsTimeRuning } = useGame(); + + const [activeSlide, setActiveSlide] = useState(0); + + function setNextSlide() { + setActiveSlide(activeSlide + 1); + } + function setPreviousSlide() { + setActiveSlide(activeSlide - 1); + } + function startGame() { + setIsTimeRuning(true); + setHasCheckedTutorial(true); + } + + return ( +
+ + {activeSlide === 0 && } + {activeSlide === 1 && ( + + )} + {activeSlide === 2 && ( + + )} + +
+ ); +} diff --git a/src/components/tutorials/Walkthrough.jsx b/src/components/tutorials/Walkthrough.jsx new file mode 100644 index 0000000..3c874ff --- /dev/null +++ b/src/components/tutorials/Walkthrough.jsx @@ -0,0 +1,52 @@ +import React from "react"; +import Lottie from "lottie-react"; +import { motion } from "framer-motion"; + +import animationPoints from "../../assets/animations/ecran-deroulement.json"; +import Loading from "../animations/Loading"; +import { useUser } from "../../hooks/useUser"; + +export default function Walkthrough({ setNextSlide, setPreviousSlide }) { + const { screensTranslations } = useUser(); + + if (!screensTranslations || !screensTranslations.tutorial) return ; + const currentScreenTranslations = screensTranslations.tutorial; + + const animationParameters = { + initial: { x: "100%", opacity: 0 }, + animate: { x: "0%", opacity: 1 }, + exit: { x: "-100%", opacity: 0 }, + }; + return ( + +
+

{currentScreenTranslations.how_to_play}

+

{currentScreenTranslations.walkthrough}

+ +

{currentScreenTranslations.walkthrough_description}

+
+ + +
+
+
+ +
+
+ ); +}