Skip to content

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Earth Day Waste Sorting Challenge

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.

React TypeScript Tailwind CSS Vite


๐ŸŽฎ What Is This?

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.


โœจ Features

๐ŸŒฑ Earth Day Theme

  • 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

๐ŸŒ Earth Day Mode (April 22nd only)

  • 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

๐Ÿ“š Educational Fact Cards

  • 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

๐Ÿ“Š Impact Tracker

  • 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! ๐ŸŒ"

๐Ÿ—‘๏ธ 60+ Waste Items

  • 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

๐Ÿ† Eco_Score System

  • 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

๐ŸŽฎ Five Game Modes

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 Progression

  • 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

  • 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

๐ŸŒ Educational Hub

  • "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

๐Ÿ› ๏ธ Tech Stack

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

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18 or later
  • npm 9 or later

Installation

# 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 dev

Open http://localhost:3000 in your browser.

Build for Production

npm run build
npm run preview

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ 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

๐Ÿงช Testing

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 vitest

Key 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

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.


๐Ÿ“Š Scoring Reference

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

๐Ÿ… Performance Ratings

Rating Accuracy
๐ŸŒฑ Eco Novice < 50%
โ™ป๏ธ Eco Learner 50โ€“74%
๐ŸŒฟ Eco Warrior 75โ€“89%
๐ŸŒ Eco Champion 90โ€“100%

๐Ÿค Contributing

Contributions are welcome! If you want to add more waste items, improve educational facts, or enhance accessibility, please open an issue or pull request.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-improvement
  3. Commit your changes: git commit -m 'Add more organic waste items'
  4. Push to the branch: git push origin feature/my-improvement
  5. Open a Pull Request

๐Ÿ“„ License

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.

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages