11import React , { useState } from 'react' ;
22import { Minesweeper } from '@minigames-react/minesweeper' ;
33import '@minigames-react/minesweeper/dist/index.css' ;
4+ import { Dino } from '@minigames-react/dino' ;
5+ import '@minigames-react/dino/dist/index.css' ;
46import './App.css' ;
57
68interface GameResult {
@@ -26,6 +28,7 @@ const difficulties: Record<Difficulty, DifficultyConfig> = {
2628function App ( ) {
2729 const [ difficulty , setDifficulty ] = useState < Difficulty > ( 'easy' ) ;
2830 const [ gameResult , setGameResult ] = useState < GameResult | null > ( null ) ;
31+ const [ dinoResult , setDinoResult ] = useState < { score : number ; time : number } | null > ( null ) ;
2932 const [ key , setKey ] = useState ( 0 ) ;
3033
3134 const config = difficulties [ difficulty ] ;
@@ -34,6 +37,10 @@ function App() {
3437 setGameResult ( result ) ;
3538 } ;
3639
40+ const handleDinoFinish = ( result : { score : number ; time : number } ) => {
41+ setDinoResult ( result ) ;
42+ } ;
43+
3744 const handleDifficultyChange = ( newDifficulty : Difficulty ) => {
3845 setDifficulty ( newDifficulty ) ;
3946 setGameResult ( null ) ;
@@ -102,6 +109,26 @@ function App() {
102109 </ div >
103110 ) }
104111 </ div >
112+
113+ < div className = "game-card" >
114+ < h2 > 🦕 Dino Game</ h2 >
115+
116+ < div className = "game-info" >
117+ < p >
118+ < strong > How to play:</ strong >
119+ </ p >
120+ < p > Press SPACE or ↑ to jump, ↓ to duck</ p >
121+ < p > Avoid obstacles and survive as long as you can!</ p >
122+ </ div >
123+
124+ < Dino onFinish = { handleDinoFinish } speed = { 1 } />
125+
126+ { dinoResult && (
127+ < div className = "game-result" >
128+ 🦕 Game Over! Score: { Math . floor ( dinoResult . score ) } | Time: { dinoResult . time . toFixed ( 1 ) } s
129+ </ div >
130+ ) }
131+ </ div >
105132 </ div >
106133 </ div >
107134 ) ;
0 commit comments