New Features Guide:

Basic Brick (1 hit)
Strong Brick (2 hits)
Moving Brick
Speed Power-up
Multi-Ball Power-up
Wide Paddle Power-up

Click here to go back to main page

Enhanced OOP Breakout Game

Enhanced Object-Oriented Programming Architecture:

  • GameObject Base Class: Enhanced with collision detection methods
  • Ball Class: Now supports multiple ball instances
  • Paddle Class: Enhanced with multiple power-up types
  • Brick Class (Base): Foundation class for all brick types
  • StrongBrick Class: Inherits from Brick, requires 2 hits
  • MovingBrick Class: Inherits from Brick, moves horizontally
  • PowerUp Class (Enhanced): Multiple power-up types with different effects
  • Game Class: Manages arrays of objects and inheritance

Controls: Use arrow keys or mouse to move paddle

Hack #1 (90%): Change Colors

Look in the JavaScript classes and change the paddle and brick colors.

  • Pick a new color for the paddle and the different brick types.
  • Change colors in the Ball, Paddle, BasicBrick, StrongBrick, and MovingBrick class constructors.
  • Tip: Each brick type has its own color - experiment with different combinations!

Hack #2 (90%): Modify Brick Types

Look at the different brick classes and modify their properties.

  • Change how many hits StrongBrick requires by modifying this.hits in the constructor.
  • Change MovingBrick speed by modifying this.speed.
  • Adjust the percentage of each brick type in the createRandomBrick() method.

Hack #3 (90%): Power-Up Modifications

  • Change power-up probabilities in the getRandomPowerUpType() method.
  • Modify power-up durations by changing values in the powerUpDurations object.
  • Adjust the multi-ball count in the applyPowerUp() method.

Hack #3 (100%): Create New Brick Types

  • Challenge: Create an ExplosiveBrick class that destroys nearby bricks when hit.
  • Advanced: Make a ShieldBrick that becomes indestructible after being hit once.
  • Expert: Add your new brick type to the createRandomBrick() method.

Advanced OOP Challenges:

  • Inheritance Practice: Override the draw() method in brick subclasses for unique visuals.
  • Polymorphism: Add a getPoints() method to each brick type with different values.
  • Encapsulation: Create private methods in brick classes using the # syntax.
  • Composition: Create a BrickFactory class to manage brick creation.
  • Array Management: Study how the game handles arrays of different object types.

Enhanced OOP Breakout Game Lesson

Learn Advanced Object-Oriented Programming

This enhanced version demonstrates inheritance, polymorphism, and array management with multiple object types.

  • See how subclasses inherit and override parent class methods.
  • Understand polymorphism with different brick types behaving differently.
  • Learn to manage arrays containing different object types.
  • Practice extending existing classes with new functionality.
  • Explore how inheritance makes adding new features easier.

Click here to read the full lesson