Skip to content

t7y/math_tower_defense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏰 Math Tower Defense

An educational tower defense game designed for grade 4 students that combines curriculum-aligned math questions with engaging gameplay mechanics.

🎮 Game Overview

Math Tower Defense is a two-phase educational game:

  1. Math Quiz Phase: Complete 5 grade 4 math questions to unlock tower defense gameplay
  2. Tower Defense Phase: Defend against waves of lava chicken enemies while solving bonus math problems

🔥 Featured Enemies: Lava Chickens!

  • Regular Lava Chickens: Fiery chickens with glowing lava effects and animated drips
  • Shielded Variants: Rare enemies (5% spawn chance after wave 3) with protective energy shields

🎯 Educational Features

Math Quiz (5 Questions)

  • Grade 4 curriculum-aligned questions covering:
    • Addition & Subtraction
    • Multiplication & Division
    • Fractions
    • Geometry
    • Word Problems
  • Performance-based unlock system
  • Immediate feedback with explanations

Bonus Math Problems (3 per wave)

  • Appear every 3rd wave during tower defense
  • Earn extra gold for correct answers
  • Encourage continued learning during gameplay
  • Optional - can be skipped to continue playing

🏗️ Tower Defense Mechanics

Tower Types

  • 🗼 Basic Tower (20 gold): Standard damage, balanced stats
  • ❄️ Ice Tower (40 gold): Slows enemies, moderate damage
  • 🔥 Fire Tower (60 gold): High damage with splash effect

Enemy Types

  • Basic Lava Chicken: Standard HP and speed
  • Fast Lava Chicken: Lower HP but increased speed
  • Strong Lava Chicken: High HP but slower movement
  • Shielded Variants: Any type can spawn with protective shields

Game Progression

  • Waves increase in difficulty and enemy count
  • Performance unlocks determine available towers and abilities
  • Local progress tracking maintains unlocks between sessions

🚀 Getting Started

Prerequisites

  • Modern web browser with JavaScript enabled
  • No additional installations required

Running the Game

  1. Open index.html in your web browser
  2. Complete the 5-question math quiz
  3. Enjoy tower defense gameplay!

Development Setup

# Clone the repository
git clone [repository-url]
cd math_tower_defense

# Open in browser
open index.html

🎵 Audio Features

  • Background Music: Disabled by default, can be enabled in settings
  • Sound Effects: Comprehensive audio feedback for all game actions
  • Dynamic Audio: Dramatic countdown effects and contextual sounds
  • Volume Controls: Separate controls for music, SFX, and master volume

📁 Project Structure

math_tower_defense/
├── index.html              # Main game interface
├── app.js                  # Application controller
├── style.css              # Global styles
├── quiz/
│   ├── QuizSystem.js      # Math quiz logic
│   └── questions.js       # Question database
├── game/
│   ├── GameEngine.js      # Core tower defense mechanics
│   └── GameEngine3D.js    # 3D rendering extension
├── math/
│   └── BonusSystem.js     # Bonus question system
├── progress/
│   └── ProgressTracker.js # Local storage & analytics
└── ui/
    └── audio/
        └── AudioSystem.js # Sound effects & music

🎮 How to Play

Quiz Phase

  1. Answer 5 grade 4 math questions
  2. Review explanations for each answer
  3. Your performance determines tower unlocks

Tower Defense Phase

  1. Place Towers: Click a tower type, then click on the game field
  2. Start Waves: Click "Start Wave" or wait for auto-countdown
  3. Defend: Towers automatically target and shoot enemies
  4. Bonus Questions: Solve 3 math problems every 3rd wave for extra gold
  5. Survive: Don't let enemies reach the end!

Controls

  • Mouse: Place towers and interact with UI
  • Space: Pause/resume game
  • Click: Select towers and answer questions

🏆 Performance & Unlocks

Quiz performance determines starting advantages:

  • Excellent (90%+): All towers, abilities, hard difficulty
  • Great (80-89%): Basic + Ice + Fire towers, speed boost, normal difficulty
  • Good (70-79%): Basic + Ice towers, normal difficulty
  • Fair (60-69%): Basic + Ice towers, easy difficulty
  • Needs Practice (<60%): Basic tower only, easy difficulty

🔧 Technical Features

  • Canvas-based Rendering: Smooth 60fps gameplay
  • Responsive Design: Adapts to different screen sizes
  • Local Storage: Progress persists between sessions
  • Modular Architecture: ES6 modules for maintainability
  • No Dependencies: Pure JavaScript implementation

🎨 Visual Features

  • Lava Chicken Enemies: Custom-drawn animated creatures with:
    • Glowing lava effects
    • Animated dripping lava
    • Evil red eyes
    • Chicken anatomy (beak, comb, tail feathers, claws)
  • Energy Shields: Rare enemies with animated hexagonal shields
  • Dynamic Countdown: Visual and audio countdown effects
  • Particle Effects: Smooth projectiles and impact feedback

🧠 Educational Standards

Aligned with Grade 4 mathematics curriculum:

  • Number Operations: Multi-digit addition, subtraction, multiplication, division
  • Fractions: Basic fraction concepts and equivalence
  • Geometry: Shape properties, perimeter calculations
  • Problem Solving: Real-world application word problems

🔊 Sound Design

  • Procedurally Generated: All sounds created using Web Audio API
  • Contextual Audio: Different sounds for each tower type and action
  • Musical Elements: Background music with melody and bass lines
  • Dramatic Effects: Escalating countdown sounds and victory fanfares

🚧 Development Notes

Key Design Decisions

  • Educational First: Game mechanics support learning objectives
  • Age-Appropriate: Visual design and difficulty suitable for grade 4
  • Local-Only: No external servers, works offline
  • Performance Optimized: Efficient rendering for smooth gameplay

Future Enhancements

  • Additional grade levels
  • Multiplayer functionality
  • Teacher dashboard
  • Extended curriculum integration

🤝 Contributing

This is an educational project designed for grade 4 students. When contributing:

  • Maintain age-appropriate content
  • Follow curriculum alignment
  • Ensure accessibility
  • Test on various devices
  • Keep educational value central

📜 License

Educational use encouraged. Please maintain attribution and educational focus in any derivatives.


Built with ❤️ for young mathematicians and tower defense enthusiasts!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published