Description
From Breakout.java:
/* ***************************************************************************
* ;j:
* D L:
* , L.
* .jLGGGLLLfjt;,: _:f Wj .
* ,tG ______________ E. jf
* , < ____ / K, t G
* f / / /___/ GjjG G
* iGW / /___ _______ f_____ ______________ __ ___
* :f / ____/ < ___ \ / __ \ < __ __ \ < \ / /
* ;D / / ____ / / / / / /_/__/ / / / / / / \ / /
* iE / /____/ / / / / / / /___ / / / / / / \ /
* ;DDLjijK <_____________/ <___> /___> \______> <___> <___> <___> / /
* . : _____________ K: :;jt / /
* ; < ____ \ KW Wf. <___>
* L / / / / Wf.
* .W / /___/ / ___Gi__ ______ ______
* ; / ____ < / ___ \ / ___> / ___>
* j WW / / / / / / / / \ < \ <
* f#K; :j / /___/ / / /__/ / ___> \ ___>
* jW. ,E <_____________/ \ ______/ <______/ <______/
* ,, G GttfLGDKKW Ef,
* iK t ...... Copyright (c) 2005 Mujtaba Hasni
* jW D
* iDj http://enemyboss.net
* : enemyboss@gmail.com
*
*
*
* The MIT License
*
* Copyright (c) 2005 Mujtaba Hasni www.enemyboss.net
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* * * *
*
*
* -[ E N E M Y B R E A K O U T ]-
*
*
* -={ R e v i s i o n H i s t o r y }=-
*
* Version 1.0a / Jun. 02 2005 / Alpha Release.
*
*
* -={ D e s c r i p t i o n }=-
*
* Enemy Breakout is a very simple clone of Atari 2600's Super Breakout.
* Creating breakout is a good exercise in basic collision detection, and
* trigonometry. The objective is simple, score as many points as you can by
* breaking coloured bricks before all your lives run out.
*
* Destory all bricks to advance to the next level. Each time you clear a
* level, you gain an extra life. I've hard-coded 5 unique stages, which do
* repeat. These stages are stored in the levelMaps array.
*
* -={ Build and Installation }
*
* Building Enemy Breakout requires Java2 SE SDK 1.4 or greater, java.sun.com.
* command: javac Breakout.java
*
* To play, place this inside HTML document or use appletviewer on this file:
* <applet code="Breakout.class" width="640" height="480"></applet>
*
* -={ G a m e p l a y }=-
*
* 1. To begin game, click the mouse button.
*
* 2. At the beginning of each round, you serve the ball by clicking the
* mouse button. The serve goes straight upwards.
*
* 3. Score points by breaking colored bricks. Green and blue bricks become
* yellow and magenta, respectively after begin hit. So these take two hits
* to break:
*
* Yellow = 1 point.
* Magenta = 3 points.
* Green = 5 points.
* Blue = 7 points.
*
*
* 4. The angle at which the ball deflects off the paddle depends where on
* the paddle the ball touches. The ball will also speed up every 7 hits off
* the paddle.
*
* 5. If the ball touches the back wall ( breaks through ) the paddle will
* shink to half size. The paddle size will be restored next level or life.
*
*
* -={ G a m e D e s i g n }=-
*
* I use a 2D integer array to represent the brick wall. There are several
* brick types identified by integers. The wall has a maximum of 11 columns
* and 5 rows. Each brick type has a specific color and point values. Some
* bricks take more hits to break than others.
*
* I use two functions, gridToScreen() and screenToGrid() that let me convert
* (x,y) screen coordinates to column/row indices in the array, and
* vice-versa. I use these to determine where to draw a brick, and when the
* ball is touching a brick.
*
* The ball will deflect at an angle that depends on which of the 8 sections
* of the paddle it touches. This behavior makes the paddle appear concave.
* These deflection angles are stored in the array deflectionAngles[] in the
* hitBall() function. As for walls and bricks, the ball simply reflects at
* a 45 degree angle. Like in Pong.
*
* Oh, what else? ... yeah, BLOODY EYE-SEARING RED! Everywhere. And I'll do it
* again, for sure.
*
* -={ F i n a l N o t e s }=-
*
* I originally incorporated the concept of "chaining" where you could
* rack-up bonus points by breaking multiple bricks of the same color in a
* row. I removed it because it gave less insentive for players to use a more
* balanced play strategy.
*
* The MIDI sequence, for those who want to know, is a remix of Capcom's Mega
* Man 2, Clash Man's stage by Anthony Bellissimo <twon@ici.net> from
* Vgmusic.com. Vgmusic.com has a lot of MIDI's of your favorite games, made
* by the fan community. Unfortunately, Java's default installed sound bank
* is terrible. So one has to careful in choosing which midi sequence to use.
*
* I tried to make this game enjoyable, while keeping the code simple and
* small. I also made plenty of comments so that new programmers should be
* able to read it.
*
*
* Enjoy,
*
* - mujtaba
*
* --------------------------------------------------------------------------
*/
System Requirements
Java2 plug-in or Java2 SE SDK >= 1.4.
Screenshots
|