How vagnernerves/flappy-bird works
Project type and purpose
• This is a single-page mobile game (a Flappy Bird clone) built with React Native and Expo.
• It uses TypeScript for type safety, react-native-game-engine for game loop and entity management, and Matter.js for physics simulation.
File structure
• Top-level entry:
• App.tsx – root component, sets up the Game Engine and navigation between screens.
• app.json, babel.config.js, tsconfig.json – Expo and TypeScript configuration.
• src/@types – custom TypeScript definitions (e.g. images).
• src/assets – static assets (images, logo).
• src/components – UI/game components: Bird, Floor, Obstacle (each with index.tsx and styles.ts).
• src/entities – entity definitions and registration for the game engine (logic and initial parameters).
• src/screens – screen hierarchy:
• Home – wrapper for game;
• Home/Game – hosts the game engine and two sub-screens: Start and GameOver;
• src/utils – helper functions (physics setup, randomization).
README for additional insights
• Technologies section confirms: Expo, React Native, TypeScript, SplashScreen, react-native-game-engine, Matter.js.
• Purpose: tap to make bird fly, pass through obstacles.
Components
a. Mobile Client (React Native/Expo)
• App container (App.tsx)
• Navigation/Screen Manager
b. Game Engine Layer (react-native-game-engine)
• Entity Manager (Bird, Floor, Obstacle)
• Game Loop (update, physics, render)
c. Physics Engine (Matter.js)
• World/Engine instance
• Bodies and constraints
d. UI Components & Screens
• Start Screen (awaiting tap)
• Game Screen (active play)
• GameOver Screen (score display, restart)
e. Utilities & Assets
• Physics utilities (src/utils/physics.ts)
• Randomization (src/utils/ramdom.ts)
• Image assets loader (Expo Asset)
Relationships and data flows
• User taps → Input handler in Game Engine → triggers physics impulse on Bird entity
• Game Loop tick → Physics Engine updates positions → Entities update state → Components render updated positions
• Entity state changes → Screen transitions (Start → Game → GameOver)
• Asset loader feeds images to components before initial render
Architectural patterns & design principles
• Component-based UI (React Native)
• Entity-Component pattern (react-native-game-engine)
• Separation of concerns: game logic (entities + utils), rendering (components + styles), configuration (tsconfig, Expo)