Sort Smarter. Save the Planet.
An educational drag-and-drop waste sorting game built to celebrate Earth Day (April 22nd) and deepen players' understanding of real-world recycling, environmental impact, and sustainable habits.
The Earth Day Waste Sorting Challenge is a fast-paced, educational web game where players drag waste items into the correct recycling, organic, or hazardous bins. Every correct sort teaches a real environmental fact and tracks your estimated real-world impact โ kilograms of waste diverted from landfill and COโ equivalent saved.
The game features a special Earth Day Mode that activates on April 22nd each year, a curated library of 60+ waste items, five distinct game modes, and a full impact tracker that makes every sort feel meaningful.
- Earth-green color palette (
#2d6a4f,#52b788) with parallax scrolling background - Animated ๐ globe and "Sort Smarter. Save the Planet." tagline on the home screen
- Animated falling leaves and "๐ Happy Earth Day!" banner on April 22nd
- "Next Earth Day" countdown displayed year-round
- Curated set of 30 high-impact waste items
- Countdown timer to midnight (end of Earth Day)
- Special "Earth Day Champion" results card with shareable summary
- Green confetti on every correct sort
- Every sort (correct or incorrect) shows a real environmental fact
- Decomposition times, COโ figures, and recycling science
- Color-coded borders matching the correct bin category
- "Did you know?" prefix for counterintuitive "trick" items
- Zen mode: facts stay visible until you dismiss them
- Live display of estimated kg of waste diverted from landfill
- Live display of estimated kg COโe saved
- Planet Health Bar fills from 0โ100% as you sort correctly
- Full-screen celebration at 100%: "You've made a real difference today! ๐"
- Covers food packaging, garden waste, household chemicals, electronic accessories, construction materials, and medical waste
- Difficulty 1โ3 with progressive unlocking
- At least 5 "trick" items (e.g. greasy pizza box โ Organic, broken glass โ Hazardous)
- Every item has a unique fact of at least 20 words
base_points ร combo_multiplier + speed_bonus + impact_bonus- Difficulty-weighted base points: 10 / 15 / 25
- Combo multipliers: ร1.0 โ ร1.2 โ ร1.5 โ ร2.0
- Speed bonus (+5 pts) for sorts under 2 seconds
- Impact bonus:
floor(impactKg ร 10)per item
| Mode | Description |
|---|---|
| Classic | 60-second timer โ sort as many items as possible |
| Time Attack | 20 items โ correct sorts add 3s, wrong sorts subtract 5s |
| Survival | 3 lives โ mistakes and slow sorts cost a life |
| Zen | No timer, no penalties โ read every fact at your own pace |
| Earth Day | April 22nd only โ curated 30-item challenge |
- Level up every 10 correct sorts
- Difficulty-2 items unlock at Level 4, difficulty-3 at Level 7
- Spawn delay decreases 50ms per level (minimum 200ms)
- Accessibility Mode: +25% font sizes, 64ร64px touch targets, high-contrast palette, reduced motion
- Full keyboard navigation: Tab/arrow keys to cycle bins, Enter/Space to confirm
- ARIA labels on all bins and draggable items
- WCAG 2.1 AA contrast compliance
- "About Earth Day" screen: history (founded 1970), global significance, 3 actionable tips
- "Did You Know?" rotating fact panel on the home screen (10 facts, 5s interval)
- Visual Recycling Guide: all 6 categories with 5 example items each
- "Take Action" suggestions on the results screen
| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| TypeScript 5.8 | Type safety |
| Tailwind CSS 4 | Styling and responsive layout |
| @dnd-kit/core | Touch-friendly drag-and-drop |
| framer-motion | Spring animations, layout transitions |
| canvas-confetti | Celebration effects |
| Vite 6 | Build tool and dev server |
| Vitest + fast-check | Unit and property-based testing |
- Node.js 18 or later
- npm 9 or later
# Clone the repository
git clone https://github.com/mohamednizzad/Waste-Sorting-Challenge.git
cd Waste-Sorting-Challenge
# Install dependencies
npm install
# Start the development server
npm run devOpen http://localhost:3000 in your browser.
npm run build
npm run previewsrc/
โโโ components/
โ โโโ GameScreen.tsx # Main game layout (refactored from WasteGame)
โ โโโ HomeScreen.tsx # Home screen with Earth Day theme
โ โโโ ModeSelectScreen.tsx # Game mode selection
โ โโโ ResultsScreen.tsx # End-of-session results
โ โโโ AboutEarthDayScreen.tsx # Earth Day educational hub
โ โโโ RecyclingGuideScreen.tsx# Visual recycling guide
โ โโโ DraggableItem.tsx # Draggable waste item card
โ โโโ DroppableBin.tsx # Droppable bin target
โ โโโ FactCard.tsx # Post-sort educational fact panel
โ โโโ ImpactTrackerPanel.tsx # Live impact metrics display
โ โโโ PlanetHealthBar.tsx # Progress bar toward 100% impact
โ โโโ EarthDayOverlay.tsx # April 22nd decorations
โโโ hooks/
โ โโโ useGameEngine.ts # Full game loop logic
โ โโโ useEarthDay.ts # Earth Day detection (injectable clock)
โ โโโ useAccessibility.ts # Accessibility mode (localStorage)
โโโ logic/
โ โโโ scoring.ts # Pure scoring functions
โ โโโ levelGating.ts # Level/difficulty/spawn logic
โ โโโ impactCalc.ts # Impact accumulation + planet health
โ โโโ performanceRating.ts # Eco Novice โ Eco Champion rating
โ โโโ sessionSerializer.ts # JSON round-trip serialization
โ โโโ prettyPrinter.ts # Human-readable session summary
โโโ data/
โ โโโ gameData.ts # WasteItem + CategoryInfo + 60+ items
โ โโโ earthDayData.ts # Facts, tips, Earth Day theme, tags
โโโ App.tsx # Screen navigation state machine
โโโ main.tsx # React entry point
โโโ index.css # Global styles + accessibility overrides
The project uses Vitest for unit tests and fast-check for property-based testing. 18 correctness properties are verified across all pure logic modules.
# Run all tests (single pass)
npx vitest --run
# Run tests in watch mode
npx vitestKey property tests include:
- Eco_Score formula correctness โ for any valid inputs, the formula holds exactly
- Score never goes negative โ for any sequence of sorts, score โฅ 0
- Session serialization round-trip โ serialize โ deserialize produces identical state
- Malformed input never throws โ deserializer always returns an error object, never throws
- Level gating difficulty ceiling โ available items always respect the current level cap
Earth Day Mode activates automatically on April 22nd each year. It presents a curated set of 30 waste items chosen for their real-world environmental impact, displays a countdown to midnight, and awards an "Earth Day Champion" results card on completion.
On all other days, the home screen shows a "Next Earth Day" countdown so players always know how many days remain.
Eco_Score = floor(base_points ร combo_multiplier) + speed_bonus + impact_bonus
Base points: Difficulty 1 โ 10 pts | Difficulty 2 โ 15 pts | Difficulty 3 โ 25 pts
Combo multiplier: ร1.0 (1โ2) | ร1.2 (3โ4) | ร1.5 (5โ9) | ร2.0 (10+)
Speed bonus: +5 pts if sorted within 2 seconds (not in Zen mode)
Impact bonus: floor(impactKg ร 10) pts per item
Wrong sort: โ5 pts (minimum 0), combo resets to 0
| Rating | Accuracy |
|---|---|
| ๐ฑ Eco Novice | < 50% |
| โป๏ธ Eco Learner | 50โ74% |
| ๐ฟ Eco Warrior | 75โ89% |
| ๐ Eco Champion | 90โ100% |
Contributions are welcome! If you want to add more waste items, improve educational facts, or enhance accessibility, please open an issue or pull request.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-improvement - Commit your changes:
git commit -m 'Add more organic waste items' - Push to the branch:
git push origin feature/my-improvement - Open a Pull Request
MIT License โ see LICENSE for details.
๐ Happy Earth Day โ Sort Smarter, Save the Planet ๐ฑ
Crafted By Mohamed Nizzad with ๐ for Google AI Studio motivated by Dev.to.