Coder Social home page Coder Social logo

brickbreaker's Introduction

Brick Breaker

This is a game based on the popular "breakout" game from the 1970s made for a school class. It uses object-oriented programming and inheritance, with most classes extending the CollisionObject class. This allowed me to reduce much of my main code (Frame.java) extensively so my code could be concise.

Gameplay

gamplay (The gif is actually slightly too slow, and the game is usually faster)

The Paddle can move left and right, and the ball bounces around the frame. The aim of the game is to break all of the bricks by blocking the ball's path by moving the paddle (with the left and right arrow keys) in order to collect points and move onto the next level while not losing three lives.

Each brick color has a different health and point value.

  • Red bricks have 1 health and are worth 100 points
  • Green bricks have 2 health and are worth 150 points
  • Yellow bricks have 3 health and are worth 250 points

If the ball ever passes under the paddle, you will lose a life (shown by the heart count in the top left corner of the game screen). If you drop to 0 lives, the game ends.

Also, you can aim the ball slightly by moving your paddle in the direction that you want it to go (when they collide). This is a particularly useful feature, and it makes the game actually fun to play (instead of highly irritating).

level one

Levels

The game includes three levels with a different arrangement of bricks. Level-ups happen automatically, as soon as you break the last brick and pass the ceiling.

level two

Level one:

level one

Level two:

level two

Level three:

level three

This is accomplished by defining the brick formats using 2D string arrays and parsing through them. level two

The parser: level two

Collisions

Nearly all objects extend the CollisionObject class so that any colliding object, like the ball, can be passed to each brick easily. The collision detection is accomplished by relying on the Rectangle class and its intersects() method. Then, depending on the position of the argument object to the current object, the direction of the ball is switched.

level two

This also allows all of the extending classes to be very simple, each with only a few methods and roughly 100 lines of code.

brickbreaker's People

Contributors

seanboe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.