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

 
 
 

Contributors