Description
From Invaders.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 I N V A D E R S ]-
*
*
*
* ######
* ##########
* ############
* ## ## ## ## ##
* ################
* ### ## ###
* # #
*
*
* ## ## ## ##
* #### #### #### ####
* ###### ###### ###### ######
* ## ## ## ## ## ## ## ## ## ## ## ##
* ######## ######## ######## ########
* # # # # # # # #
* # ## # # ## # # ## # # ## #
* # # # # # # # # # # # # # # # #
*
* # # # # # #
* # # # # # # # # # # # #
* # ####### # # ####### # # ####### #
* ### ### ### ### ### ### ### ### ###
* ########### ########### ###########
* ######### # ######### #########
* # # # # # # #
* # # # # # # #
* #
* #### # ####
* ########## # ##########
* ############ # ############
* ### ## ### # ### ## ###
* ############ ### ############
* ## ## # ## ##
* ## ## ## ## ## ##
* ## ## ## ##
*
*
*
* #
* ###
* ###
* #############
* ###############
* ###############
* ###############
* ###############
*
*
* -={ 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 Invaders is a clone of the first Arcade hit, Space Invaders '78.
* This game uses many more moving sprites than breakout, these include the
* alien invaders, the bombs, the bullets, the occasional UFO, and of course,
* the gunship itself.
*
* Space invaders is a good exercise in basic sprite programming, and use of
* tick timers. I show a simple way to render bitmap images and fonts, which
* a re stored as literal Strings in the code. The game also uses the
* keyboard instead of the mouse.
*
* The Space Invader craze is legendary, which was only succeeded by pac-man
* fever three years later. The game came out before I was born, but my first
* experience playing Space Invaders was on the Commodore Vic-20. I think
* almost all gamers of my generation and before has played this game. And I
* haven't met anyone hadn't enjoyed the game back in the day. The game is a
* classic, period.
*
*
* -={ G a m e p l a y }=-
*
* 1. Use your gunship to destroy all the invaders before they reach the
* earth, while avoiding bombs they drop on you.
*
* 2. Defend yourself using the four energy shields or by nullifying bombs
* with your bullets. Your shields slowly drains energy as they're hit until
* they dissapear.
*
* 3. There are three types of aliens, worth 10, 20 and 30 points each.
*
* 4. Sometimes, a mysterious UFO will appear, shoot it to earn 150, 300 or
* even 500 bonus points!
*
* 5. Every 1000 points you earn will give you an extra life.
*
*
* -={ N o t e s }=-
*
* The "Energy" Shields
*
* The shields works differently from the arcade original. The shields fade
* away as they're being hit, instead of eroding. It would have been
* overly complex to do in Java, especially with doublebuffering.
*
* I imagine that the original game's code performed its collision
* detection against the colour of pixels. So whenever a bullet or bomb hit
* a shield, it would black-out blasted portions of the shield, allowing
* bullets and bombs to pass through.
*
* If I were working directly with a display buffer, this would be easy to
* implement. The Image class doesn't allow access to its pixels, and it
* would require the use of MemoryImageSource and PixelGrabber classes, or
* Java2's BufferedImage class.
*
* Images and Sounds, Credits
*
* The sound effects I believe were originally sampled from the analog
* circuits that the original Space invaders cabinet used. The actual .wav
* files were extracted from a sound pak found on the Space Invaders
* Didactic Emulator (SIDE) home page:
*
* http://www.ascotti.org/programming/side/side.htm.
*
* I needed bitmapped graphics so I encoded them as strings. The ASCII art
* is based on James Eibisch' Space Invaders QBASIC code. I also encoded a
* bitmap font. Doing this way also allows me to use the Graphics' class
* fill3DRect() method to make that scan-line effect.
*
* I encoded the graphics this way to make this file self contained. I
* imagine one could copy & paste this code from a newsgroup, compile it,
* and have a playable game. Its fine to play a game without sound
* effects but without graphics? I think not.
*
* Making It Easy
*
* I could have made this game much more simpler than this. For example, I
* could have loaded the sprites from GIFs, and use Java's own font
* rendering like ususal. The design could also be cleaner had I chose to
* create custom classes. Also, my game loop doesn't work purely into its
* seperate stages.
*
* I am trying to be serious with my code quality and readability. But I
* also decided to make code that was self contained, and use only the
* class already standard on the Java2 platform. It could use more work,
* but I think I've done the job.
*
* - mujtaba
*
* ---------------------------------------------------------------------------
*/
System Requirements
Java2 plug-in or Java2 SE SDK 1.4 or greater.
Screenshots
|