@cds.id/fruits-ninja
v1.0.1
Published
A Fruit Ninja game component for React applications
Downloads
127
Maintainers
Readme
Fruit Ninja Clone
A modern web-based clone of the classic Fruit Ninja game built with React, TypeScript, and Canvas.
🎮 Demo
[Add your demo link here]
✨ Features
- 🎯 Smooth fruit slicing mechanics
- 🍎 Multiple fruit types with different point values
- 💫 Dynamic difficulty scaling
- 🌟 Particle effects and slice trails
- 📱 Mobile and desktop support
- 🎮 Lives system
- 📊 Score tracking
- 🔄 Progressive gameplay
🛠️ Tech Stack
- React 18
- TypeScript
- Tailwind CSS
- Vite
- HTML5 Canvas
🚀 Getting Started
Prerequisites
- Node.js (v14 or higher)
- npm or yarn
Installation
- Clone the repository:
git clone https://github.com/yourusername/fruit-ninja.git
- Navigate to the project directory:
cd fruit-ninja
- Install dependencies:
npm install
# or
yarn
- Start the development server:
npm run dev
# or
yarn dev
- Open http://localhost:5173 in your browser.
🎮 How to Play
- Click "Start Game" to begin
- Slice fruits by swiping across them with your mouse or finger
- Each fruit gives different points when sliced
- Miss 3 fruits and the game ends
- Game gets progressively harder every 30 seconds
- Try to achieve the highest score!
🏗️ Project Structure
fruit-ninja/
├── src/
│ ├── assets/
│ │ └── fruits/ # Fruit images
│ ├── components/ # React components
│ ├── hooks/ # Custom React hooks
│ ├── config/ # Game configuration
│ └── types/ # TypeScript types
🎯 Game Mechanics
- Difficulty Scaling: Game difficulty increases every 30 seconds
- Lives System: Player has 3 lives, loses one for each missed fruit
- Scoring: Different fruits give different points
- Fruit Physics: Realistic throwing and slicing mechanics
- Visual Effects: Slice trails and particle effects
🔧 Configuration
Key game parameters can be adjusted in the following files:
// Game.tsx
const FRUIT_SIZE = 69
const MAX_FRUITS = 3
const SPAWN_INTERVAL = 2000
const SPAWN_VARIATION = 1000
// useFruits.ts
const GRAVITY = 0.3
const INITIAL_VELOCITY_Y = -20
🖼️ Assets
The game uses the following fruit assets:
- Apple
- Banana
- Peach
- Watermelon (Sandia)
Each fruit has multiple states:
-w
: Whole fruit-l
: Left slice-r
: Right slice-s
: Splat effect-j
: Juice particle
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Original Fruit Ninja game by Halfbrick Studios
- [List any other resources or inspirations]