CompSci 307
Spring 2019
Software Design and Implementation

Game: Breakout

If children can build, play and understand games that work, it's possible that someday they will understand and design systems that work. And the world is full of complicated systems. —Sara Corbett

Back in the 1980s, video arcade games were in their prime. Local restaurants, pubs, and arcades lured customers with all of the latest titles: Pac-man, Galaxian, Donkey Kong, Tempest, Centipede, Defender, and more. (Un)fortunately, the rise of home video game systems and home computers relegated these gems to the back storage rooms of many establishments (although tiny and big versions seem to be making a comeback). They are not forgotten, however — even today, arcade cabinets are collected by enthusiasts and arcade ROM emulation systems such as MAME allow a new generation to experience these relics first-hand on modern hardware (including, briefly, the iPad).

Breakout is a popular extension to the first cabinet arcade game, Pong, that was designed by Steve Jobs and Steve Wozniak, the founders of Apple, Inc. It was such a big hit that, to this day, it is still spawning additional game spin-offs in the form of the game Arkanoid and even inspired a platform for educational games. These games build on the basic premise of Breakout, clearing a field of bricks, but add elements of every other game imaginable. Here is a (long) video of the original gameplay and here is playlist of dozens of variants of the original game.

Simple versions of this game have been used as a programming assignment in CompSci 101 and more generally as an assignment that is highly regarded by educators as "nifty", but part of its continuing appeal is how easily the game supports complex variants, such as:

Specification

In pairs, write a Java program, using OpenJFX, to play a 2D game of Breakout, in which a ball bounces around the screen and destroys blocks as it bounces into them. The player controls a paddle to block the ball from moving off the screen. The ball may bounce off of some sides of the screen; however, if the ball moves off a specific area of the screen (typically the bottom), the player loses a life and the ball is reset to its starting position. If the player misses blocking the ball too many times, the game should end and display a message that the player lost. If all the blocks are cleared from the screen, the level should end and a new one loaded (with a different configuration of blocks). If the player clears all the levels, the game ends with a message that declares the player won.

You are welcome to look at the tutorial in the resources below or any other ones you find online to learn about OpenJFX, but your game should be distinctly different from any given examples you find (i.e., create your own Breakout game, do not simply copy one).

Design

The heart of a game is its conceptual Game Loop, which is not a literal loop since OpenJFX is actually calling your code periodically to make changes before it draws items on the screen, because it manages the entire game logic from responding to input, to updating the state of the game items, to enforcing the game's rules, to checking if the game's goals are met, to potentially much more. It is called a loop because it is responsible for managing the game actions repeatedly until the user quits. Each iteration, or frame, of the game loop is called on between 60 up to 120 times (frames per second, FPS). Game loops are typically organized around Update Methods to make it easier to add new elements — in very complex games, the game loop is factored out into a separate Game Engine so new games can be written by focusing just on the new code specific its characters, rules, and goals without modifying the Engine's game loop itself (there are many popular engines like Unity or Unreal (made in NC!)).

You are not expected to write an actual Game Engine for this project, but it does provide a context to begin thinking about issues of design and coding style:

  1. Clean code. Adhere to clean coding standards within your code, like those followed by most professional coders, encompassing everything from code formatting to structuring your code in small, single-purpose, functions.
  2. Inheritance and Polymorphism. Create abstractions within your code to define general methods that can be implemented in multiple ways in separate concrete classes.
  3. Open/Closed Principle. Structure the main parts of your project around abstractions built using inheritance and polymorphism so that later features can be more easily added on (i.e., you will find out for yourself if the code you designed really was flexible).

Project Goals

This project is intended to introduce you to

Deliverables

You will submit this project in stages:

Resources