Climate Crusaders
Climate Crusaders is a 2D educational platformer built for the NASA Space Apps Challenge. It teaches students about the impact of rising Global Mean Sea Levels (GMSL)through interactive gameplay driven by real NASA climate data. Instead of arbitrary difficulty curves, the game's water level rises based on actual recorded GMSL variations from 1993–2023, making the climate crisis tangible and urgent.
Architecture & How It Works
The project follows a modular architecture separating raw data processing from the game engine. NASA's multi-column GMSL text file is parsed by a dedicated data_readermodule into structured Python objects. These objects are then consumed by the game layer, which uses the parsed sea-level values to dynamically control the water's rise speed during gameplay. The result is a data-driven difficulty system where real climate data is the antagonist.
1. Data-Driven Difficulty (GMSL Parser)
The core “antagonist” of the game is the rising sea level. Instead of an arbitrary speed increase, the water level rises based on Global Mean Sea Level (GMSL) variations recorded by NASA from 1993 to 2023. The gmsl_reader.py module parses the raw NASA .txt data file, validates the expected 13-column format, and converts each row into a structured GMSL_Entry object.
# Each entry maps to real NASA data
class GMSL_Entry:
year: float # → Maps to game timer
GMSL_variation: float # → Maps to water rise speed (mm)
uncertainty: float # → Available for difficulty scaling2. Game Loop (Input → Update → Render)
The game runs a standard 60 FPS game loop with three distinct phases, all managed inside game.py:
- ●Input: Captured via
pygame.event.get()for both discrete actions (jumping) and continuous actions (horizontal movement via held keys). - ●Update: Handles gravity constants, velocity calculations, platform collision detection, and increments the water level based on the current GMSL data entry.
- ●Render:Uses a coordinate transformation system to keep the player centered on screen while the “world” (platforms and water) scrolls relative to the player's Y-position.camera_offset = player.rect.y - SCREEN_HEIGHT // 2
3. Collision System & Game Over Logic
The collision system uses Pygame's Rect bounding-box detection. Ground/Platform Collision resets the player's vertical velocity and re-enables jumping. Water Collision triggers the Game Overstate if the player's bounding box overlaps with the rising water level. Because the water's speed is tied to real GMSL data, the difficulty ramp is both educational and unpredictable—mirroring the actual acceleration of sea level rise over the past three decades.
Tech Stack & Tools Used
Game Engine & Language
- Python 3.x: Core language for all game logic, data parsing, and rendering.
- Pygame: 2D game framework handling the display surface, sprite rendering, event loop, and audio.
- Standard Library:
os,sys,randomfor platform generation and file I/O.
Data & Assets
- NASA GMSL Data: Real-world Global Mean Sea Level variation records (1993–2023) in multi-column text format.
- Custom Parser (data_reader): Validates 13-column format and converts raw text into structured Python objects.
- Visual Assets: PNG sprites (crab protagonist, fish) and JPG backgrounds for the ocean environment.
Architecture Diagram
📐System Architecture & Data Flow
[ ARCHITECTURE OVERVIEW ]
┌─────────────────────────────────────────────────────────┐
│ DATA LAYER │
│ │
│ NASA GMSL Data File (.txt) │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌───────────────────┐ │
│ │ data_reader/ │────▶│ GMSL Entry │ │
│ │ gmsl_reader │ │ Objects (List) │ │
│ └──────────────┘ └───────────────────┘ │
│ │ │
└───────────────────────────────┼─────────────────────────┘
│
┌───────────┴───────────┐
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ GAME LAYER │ │ PLATFORMER LAYER │
│ │ │ │
│ climate_crusaders/ │ │ platformer/ │
│ ┌──────────────┐ │ │ ┌──────────────┐ │
│ │ game.py │ │ │ │ game.py │ │
│ └──────┬───────┘ │ │ └──────┬───────┘ │
│ │ │ │ │ │
│ ┌──────┴───────┐ │ │ ┌──────┴───────┐ │
│ │ Game Loop │ │ │ │ Player Class │ │
│ │ Input→Update │ │ │ │ Platform Cls │ │
│ │ →Render │ │ │ │ Tile System │ │
│ └──────┬───────┘ │ │ └──────────────┘ │
│ │ │ │ │
│ ┌──────┴───────┐ │ └──────────────────────────┘
│ │ Physics │ │
│ │ Gravity │ │
│ │ Collision │ │
│ └──────┬───────┘ │
│ │ │
│ ┌──────┴───────┐ │
│ │ Assets │ │
│ │ Sprites/BG │ │
│ └──────────────┘ │
│ │
└──────────────────────────┘
Data Flow:
NASA .txt ──▶ gmsl_reader.py ──▶ GMSL_Entry[] ──▶ game.py
Each GMSL_Entry contains:
• year (float) → Maps to game timer
• GMSL_variation (mm) → Maps to water rise speed
• uncertainty (mm) → Available for difficulty scaling
Game Loop (60 FPS):
INPUT: pygame.event.get() → keyboard state
UPDATE: gravity + collision + GMSL water_level++
RENDER: camera_offset = player.y → draw world relativeLocal Execution & Testing
There are two versions of the game available. The standard version features a crab protagonist, while the platformer version features a fish with a more modular, class-based engine. Both versions consume the same NASA GMSL data and can be run independently:
# Install Dependenciespip install pygame# Option 1: Standard Version (Crab)cd climate_crusaderspython game.py# Option 2: Platformer Version (Fish)cd platformerpython game.pyTesting Strategy
- ●Manual Functional Testing: Verification of player mechanics, collision boundaries, and menu navigation through manual play.
- ●Data Validation: The
gmsl_reader.pyincludes validation logic to ensure the input NASA data file matches the expected 13-column format. - ●Visual Verification: Real-time display of the current year and sea level variation (mm) to verify data integration during gameplay.