Description
From Sirtet.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 ___| |
| | | | | |
|___ | ___| |___ | ___|
| | | | | |
|___| |___________| |___|
_______
| |
___| ___|
| | ___
|_______| D i s t r i b u t e d U n d e r | |
___| |___
| |
|___________|
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 |___ ___| |___ |___
_______ | | | |
|_______| _____ |___| _____ _____ |_______|
| |_ |_ _| ______ |_ _| _______ |_ _|
|_ |___ |_| |______| |_| |_______| |_|
|_| _| | | _ _| | | | | |_ | |
|___| | | | | | _| | | | _| | |
| _| | | | |_| |_ | | _|_|___ | | ___
_____|_| |_| | | |_ | |_| |_______| |_| | |
|_______| _| |_ |_| |_| _______| |
|_____| _______ | |
_______________ | | |___________|
| | | |
|_______________| | |
|_______|
_______ _______
| | | |
___| ___| R e v i s i o n H i s t o r y |___ |___
| | | |
|_______| Version 0.8a / Jun. 02 2005 / Alpha Release |_______|
___________
| |
|___ ___| _______________
| | | |
|___| D e s c r i p t i o n |_______________|
[ Introduction ]
Sirtet is Tetris spelled backwards, so guess what: This game is a Tetris
clone. Tetris was invented in Russia, 1985 by Alexey Pajitnov. Tetris became
wildy popular on the Gameboy. The fact it was initially a pack-in game boosted
gameboy sales and the game's popularity. Read about the history and
controversy of Tetris on Wikipedia.
If you've seen code from my other games, you'll notice I've begun defining
classes. The last games only defined the main applet class, so thats one. In
this game, I define 15 classes! Quite a jump eh? I like object oriented
programming and design, and I think Tetris is the best place to begin thinking
seriously of object oriented design. This is also the first time I made
extensive use of AWT components and widgets.
___
Almost all new game programmers will write a | |
Tetris clone, sooner or later. Tetris clones | | ___
have appeared on every game system, and computer | | | |
system. Even most graphic calculators will have | | | | _______
a Tetris program for it. Brown University | | | | | |
Students once rigged up a playable 14 story | | | |___ | |
tetris game on their science library building. | | | | | |
See : http://bastilleweb.techhouse.org/ |___| |_______| |_______|
Tetris is a trademark highly defended by the Tetris company, and they
will contest any game even using "tris" in its name. Thank goodness,
trademarks don't apply to the game itself. Sirtet or Tetrsi are popular
alternative names I've found.
_______
| |
[ Instructions ] |___ |
| |
* Mouse click on the start button to start game. | |
* Click on the Pause/Resume button to pause the game. | |
* Press up arrow key to rotate falling block piece. |___|
* Press right/left arrow key to move block piece right or left.
* Press down arrow key to force the block down.
_______ ___ _______
| | | | | |
|___ |___ ___| |___ ___| ___|
[ Scoring, advancing Levels ] | || || |
|_______||___________||_______|
* Score points by filling rows with blocks. Bonus points awarded for
completing single, double, triple and quadruple rows simultatnously
* Scoring Scheme: ___ ___
| | | |
single row = level * 40 points. ___| | | |___
double row = level * 100 points. | | ___ | |
triple row = level * 300 points. | ___|| ||___ |
Sirtet row = level * 1200 points. | | ___| |___ | |
|___|| ||___|
|___________|
___
* Advance a level, every 20 complete rows. ___ | |
* Blocks fall faster at higher levels. | | | |
_______ _______________ _______________ ___| | | |
| || || || | | |
___| ___||_______________||_______________||___ | | |
| | | | | |
|_______| B u i l d & I n s t a l l a t i o n |___| | |
| |
[ Build Requirements ] |___|
* Java2 SE 1.4 SDK or greater: http://java.sun.com
* Sirtet.java ( this file )
[ Data Files ]
These are .wav sound and midi sample files supplied in this archive,
which you can download from http://enemyboss.net. You can also supply
your own but the game will work well without these too.
sirtet.wav - Tetris is scored (four rows simultaneously).
placed.wav - Block is fixed into placed.
row_complete.wav - Row is complete, and removed.
gameover.wav - When board is stuffed and player loses.
music.mid - Background music.
___
[ Instructions ] | |
___| |
1. Compile Sirtet.java: javac Sirtet.java | |
2. Perpare Java Archive: jar -cvf Sirtet.jar *.class |___ |
3. Delete .class files. | |
4. Generate documentaton: javadoc -private Sirtet.java. |___|
[ Installation & Embedding ]
1. Upload Sirtet.jar and *.wav *.mid files to a web directory.
2. Insert into an HTML document:
<applet code="Sirtet.class"
archive="Sirtet.jar"
width="640" height="480"></applet>
_______ _______
| | G a m e D e s i g n & N o t e s | |
|___ |___ ___________ ___| ___|
| | | | | |
|_______| |___ ___| |_______|
| |
|___|
[ Java AWT Components ]
Enemy Sirtet makes use Java's AWT GUI components, such as push buttons and
lables. The game board is a custom lightweight component. The java Applet
class is itself a container component, which contains all other components
and uses the GridBag layout manager to arrange them. The AWT toolkit
contains many convenient classes for creating GUIs quickly. This game is a
Java GUI application.
Creating custom components are easy. Just extend the java.awt.Component
class and override the paint( Graphics g ) and getPreferedSize(). The
paint() method works exactly like the Applet paint() method, because the
Applet class itself is a component. Overriding the getPreferredSize() tells
the layout manager how to fit your custom component inside a container.
Otherwise it will appear invisible.
[ Classes ]
This code defines many classes, as opposed to one main class in previous
games I wrote. The applet class is seperated from the game core class.
Instead of implementing a KeyListener, I created an innerclass extending the
KeyAdapter class and overrided the keyPressed() method.
The game display is also its own Componenet class, which displays a matrix
of colored squares. This component is used both for the game board and the
preview window. The "Tetriminos" or blocks have a class hiearchy of their
own.
[ Block Colors ]
I was very lazy in choosing these. I used only the standard colors of the
Color class. I'm not very good at choosing exotic colors (too many of them!).
[ Music & Sounds]
My choice of music this time is an arranged version of Atari's arcade Tetris
theme (I think), by Alluro95. I found this from vgmusic.com, where I pick all
my midis these days. I pick tunes that are familiar to the games I clone, but
different enough to be really original. Alluro95 has more midis at
allruo95.tripod.com. The other sounds are all recycled from Enemy Breakout.
[ Notes ]
There's alot of room for improvements. I use no fancy effects at all. Its
really a plain version of Tetris, and really doesn't compare to the orginal.
Its still fun, and the code is simple to follow ( or so I hope ). I hope
you enjoy playing the game and parsing my code.
- Mujtaba Hasni
enemyboss@gmail.com
P.S Yeah, I want all goofy with all these Tetriminos. Just think of them
as pencil doodles.
___ _______ ___
| | | | | |
| |______ _____________ _______| |_______ _____________ _______| |
| || || | | || || |
|__________||_____________||___ |___ ___| ___||_____________||___________|
| | |
|_______|_______|
*/
System Requirements
Java2 plug-in or Java2 SE SDK 1.4 or greater.
Screenshots
|