Skip to content

mnaimfaizy/numbers-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

React Native Numbers Game ๐ŸŽฎ

A fun and interactive number guessing game built with React Native and Expo. Challenge your phone to guess the number you're thinking of!

๐Ÿ“ฑ About The Game

This is a reverse number guessing game where the phone attempts to guess a number that YOU are thinking of. You provide hints (higher or lower) to guide the phone toward the correct answer. The game tracks how many rounds it takes for the phone to guess your number.

๐Ÿ“ธ Screenshots

Start Screen Game Screen Game Over Screen

From left to right: Start Screen, Guessing Screen, Game Over Screen

โœจ Features

  • ๐ŸŽฏ Interactive number guessing gameplay
  • ๐Ÿ“Š Round tracking and game statistics
  • ๐ŸŽจ Beautiful gradient UI with custom styling
  • ๐Ÿ–ผ๏ธ Background image with opacity effects
  • ๐Ÿ“ฑ Responsive design for different screen sizes
  • ๐Ÿ”ค Custom fonts (Open Sans)
  • โšก Optimized splash screen loading
  • ๐ŸŽญ Platform-specific components (iOS/Android)
  • ๐Ÿ“ Guess history log
  • ๐Ÿ”„ Restart game functionality

๐Ÿ› ๏ธ Tech Stack

  • React Native - Mobile app framework
  • Expo SDK 49 - Development platform
  • React 18.2 - UI library
  • Expo Linear Gradient - Gradient backgrounds
  • Expo Font - Custom font loading
  • Expo Splash Screen - App loading screen
  • Expo Status Bar - Status bar styling
  • Ionicons - Icon library

๐Ÿ“‚ Project Structure

react-native-numbers-game/
โ”œโ”€โ”€ App.js                          # Main app component with navigation logic
โ”œโ”€โ”€ screens/
โ”‚   โ”œโ”€โ”€ StartGameScreen.js          # Initial screen for number input
โ”‚   โ”œโ”€โ”€ GameScreen.js               # Main game screen with guessing logic
โ”‚   โ””โ”€โ”€ GameOverScreen.js           # Victory screen with statistics
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ game/
โ”‚   โ”‚   โ”œโ”€โ”€ GuessLogItem.js         # Individual guess history item
โ”‚   โ”‚   โ””โ”€โ”€ NumberContainer.js      # Display container for numbers
โ”‚   โ””โ”€โ”€ ui/
โ”‚       โ”œโ”€โ”€ Card.js                 # Reusable card container
โ”‚       โ”œโ”€โ”€ InstructionText.js      # Styled instruction text
โ”‚       โ”œโ”€โ”€ PrimaryButton.js        # Custom button component
โ”‚       โ”œโ”€โ”€ Title.android.js        # Android-specific title
โ”‚       โ””โ”€โ”€ Title.ios.js            # iOS-specific title
โ”œโ”€โ”€ constants/
โ”‚   โ”œโ”€โ”€ colors.android.js           # Android color theme
โ”‚   โ””โ”€โ”€ colors.ios.js               # iOS color theme
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ fonts/
โ”‚   โ”‚   โ”œโ”€โ”€ OpenSans-Regular.ttf
โ”‚   โ”‚   โ””โ”€โ”€ OpenSans-Bold.ttf
โ”‚   โ””โ”€โ”€ images/
โ”‚       โ”œโ”€โ”€ background.png          # Background image
โ”‚       โ””โ”€โ”€ success.png             # Victory image
โ””โ”€โ”€ package.json

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Expo CLI
  • iOS Simulator (for macOS) or Android Emulator

Installation

  1. Clone the repository:
git clone <repository-url>
cd react-native-numbers-game
  1. Install dependencies:
npm install
# or
yarn install
  1. Start the development server:
npm start
# or
yarn start
  1. Run on your preferred platform:
# iOS
npm run ios

# Android
npm run android

# Web (limited functionality)
npm run web

๐ŸŽฎ How to Play

  1. Start Screen: Enter a number between 1 and 99 that you're thinking of
  2. Game Screen: The phone will make its first guess
    • Tap the โž– (Lower) button if your number is lower than the guess
    • Tap the โž• (Higher) button if your number is higher than the guess
  3. Game Over Screen: Once the phone guesses correctly, see how many rounds it took!
  4. Restart: Tap "Start New Game" to play again

Game Rules

  • Choose a number between 1 and 99
  • You must be honest with your hints!
  • The game detects if you provide contradictory hints
  • Each guess is logged in the guess history

๐Ÿ—๏ธ Key Components

Screens

  • StartGameScreen: Number input with validation and keyboard handling
  • GameScreen: Core game logic with binary search algorithm
  • GameOverScreen: Victory celebration with round statistics

UI Components

  • Card: Elevated container with shadow and rounded corners
  • PrimaryButton: Styled pressable button with ripple effect
  • Title: Platform-specific title component
  • InstructionText: Consistent text styling
  • NumberContainer: Highlighted number display

Game Components

  • NumberContainer: Displays the current guess prominently
  • GuessLogItem: Shows individual guesses in the history

๐ŸŽจ Styling Features

  • Linear gradient background (primary to accent colors)
  • Semi-transparent background image
  • Platform-specific color schemes
  • Responsive layouts using useWindowDimensions
  • Custom fonts with fallback support
  • Shadow effects and elevation

๐Ÿ“ฑ Platform-Specific Features

The app includes platform-specific implementations:

  • Colors: Different color schemes for iOS and Android
  • Title Component: Platform-optimized text styling
  • Status Bar: Light content style

๐Ÿ”ง Configuration

Custom Fonts

Fonts are loaded using expo-font:

  • Open Sans Regular
  • Open Sans Bold

Splash Screen

The app uses expo-splash-screen for optimized loading:

  • Prevents auto-hide during font loading
  • Smoothly transitions to the app when ready

๐Ÿ› Troubleshooting

Common Issues

  1. Fonts not loading: Clear cache with expo start --clear
  2. Module errors: Delete node_modules and reinstall
  3. Metro bundler issues: Reset with watchman watch-del-all

Clear Cache

# Clear Expo cache
npx expo start --clear

# Clear watchman
watchman watch-del-all

# Reinstall dependencies
rm -rf node_modules && npm install

๐Ÿ“ฆ Dependencies

{
  "expo": "~49.0.8",
  "expo-font": "~11.4.0",
  "expo-linear-gradient": "~12.3.0",
  "expo-splash-screen": "^0.20.5",
  "expo-status-bar": "~1.6.0",
  "react": "18.2.0",
  "react-native": "0.72.4"
}

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is open source and available for educational purposes.

๐Ÿ™ Acknowledgments

  • Built with Expo and React Native
  • Uses OpenSans font family
  • Inspired by classic number guessing games

Made with โค๏ธ using React Native & Expo

About

๐ŸŽฎ A fun and interactive reverse number guessing game built with React Native and Expo. The phone tries to guess your number based on your hints. Features beautiful gradients, smooth animations, and an engaging UI.

Topics

Resources

Stars

Watchers

Forks

Contributors