Skip to content

souviksaha97/AsteroidSmash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Asteroid Smash

Asteroid Smash is a real-time arcade-style game developed on the ESP32 microcontroller to explore and learn FreeRTOS. The player pilots a spacecraft using an IMU (Inertial Measurement Unit), dodging and shooting incoming asteroids. The game features an OLED display for visuals and a piezo buzzer for sound effects, delivering a retro gaming experience on embedded hardware.


🎯 Objectives

  • Learn and apply FreeRTOS concepts: tasks, queues, semaphores, and timers.
  • Interface with multiple peripherals: IMU, OLED, and piezo buzzer.
  • Implement real-time game logic with responsive controls and dynamic rendering.

🛠️ Hardware Requirements

  • ESP32 Dev Board
  • OLED Display (SSD1306 or SH1106, I2C)
  • IMU Sensor (e.g., MPU6050 or similar)
  • Piezo Buzzer
  • Optional: Push buttons for reset or fire control

📦 Features

  • IMU-based spacecraft control: Tilt to steer, dodge, and aim.
  • Asteroid generation and movement: Randomized spawn and trajectory.
  • Projectile system: Fire bullets to destroy asteroids.
  • Collision detection: Real-time hit and dodge logic.
  • Sound effects: Piezo buzzer feedback for shooting and collisions.
  • Multitasking architecture: Game loop, input handling, rendering, and sound run as separate FreeRTOS tasks.

🧠 FreeRTOS Concepts Used

Component FreeRTOS Feature
Game Loop Periodic Task
IMU Input Task + Queue
OLED Rendering Task + Mutex
Sound Effects Task + Timer
Collision Logic Shared Resource Access

🚀 Getting Started

  1. Clone the repository

    git clone https://github.com/yourusername/asteroid-smash-esp32.git
  2. Install dependencies

    • ESP-IDF or Arduino framework
    • FreeRTOS (included in ESP-IDF)
    • Adafruit SSD1306 / U8g2 library (for OLED)
    • MPU6050 or IMU library
  3. Connect hardware

    • Wire up OLED to I2C pins
    • Connect IMU to I2C
    • Attach piezo buzzer to a PWM-capable GPIO
  4. Build and flash

    idf.py build
    idf.py flash

🎮 Controls

  • Tilt Left/Right: Steer spacecraft
  • Tilt Forward: Accelerate
  • Button Press (optional): Fire projectile

📸 Screenshots

(Add photos or gifs of gameplay on OLED screen here)


🧪 Future Improvements

  • Add score tracking and high-score memory
  • Implement power-ups and enemy ships
  • Improve graphics with sprite animation
  • Add menu and pause functionality

📚 Learning Outcomes

This project helped me:

  • Understand task scheduling and synchronization in FreeRTOS
  • Interface multiple peripherals in real-time
  • Design a modular embedded game architecture
  • Explore sensor fusion and motion control

📄 License

MIT License. Feel free to fork, modify, and build upon it!

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors