Tetris (C++)

This program was last updated on

Friday, October 20, 2000

by

[veGAMan infErior]

[Horizontal Rule]

[Home] [Up] [Back]

[Horizontal Rule]

[Tetris Screenshot]

History

For those of you who've never played Tetris (where've you been the last 15 years???), here's a little about it.

Tetris was originally programmed by Alexey Pazhitnov in June of 1985.  For a cool site, with more Tetris history than you ever thought there was, go to The Tetris Saga.

About

Tetris has a gameboard (usu. around 15x25 units) in which it drops one of seven random pieces, called "Tetrads" (tetra - four, four block pieces):

  1. **    (box)
    **
    -----
  2. **    (Z)
     **
    -----
  3.  **   (S)
    **
    -----
  4.  *    (T)
    ***
    -----
  5. *     (J)
    ***
    -----
  6.   *   (L)
    ***
    -----
  7. ****  (line)

The player can move these pieces Left, Right, Down, and, if needs be (which it almost always needs to be), it can be rotated.  So, in addition, the pieces fall naturally (by gravity I guess).

The pieces keep stacking, until the player "completes a line."  Completing a line means that an entire row is filled with block parts.  When the player completes a line, that line is deleted, the ones above it are dropped, and points are awarded.  If four lines are deleted at once, as a cause of the placement of a single piece (the Line piece), then MAJOR points are awarded.  This is called a "Tetris"

Whenever the player deletes a certain amount of lines (usu. 10), the level increases, bringing more points and faster falling pieces!

With all challenges in place, the ceiling's the limit, literally!  Once the blocks reach the ceiling to where no more blocks can come in, the game's over.

How to Play

In the Tetris that I programmed, the player uses the following keys:

[Bullet] Esc:  Exit the game
[Bullet] Left Arrow:  Move the game piece Left
[Bullet] Right Arrow:  Move the game piece Right
[Bullet] Down Arrow:  Drop the game piece a level
[Bullet] Up Arrow:  Rotate the game piece clockwise

Get Tetris

If you're a non-programmer who just wants to play some Tetris, a collector of Tetris games, or want to see how my program runs before going through the trouble of wading through the 1000+ lines of source code for the game, then this is the spot for you.

Current Version

Since this game is still in the developmental stages, there are different versions of the game at each significant stage.  So, I will only post the newest (supposedly bug-free) version of the game, and list the rest.  If you really want an older version of the game, and don't have a C++ compiler, than just e-mail me and I will try to get you the executable for the version you wish to run.

Here's the list, from newest to oldest, of the different versions of Tetris

[Bullet] Tetris v1.0 (54KB):  This is the first real version of my Tetris.  There are no level increments (meaning that the pieces always fall at the same rate (approx. 1 space/sec).  The points are displayed after the player loses the game.  Pretty bare-boned version of the game.

See Tetris Naked

If you've played my game and are ready to see what makes it tick, came to this page just to get the source code, or you just would like a glimpse at how much goes into programming a game as "simple" as Tetris, then this is the spot for you!

Growth Chart of Tetris

Since this game is still in the developmental stages, there are different versions of the game at each significant stage.  I will try to post them all, since they are only around 12KB big.

Important Note

I wrote Tetris using Borland C++ v4.5, so here's how to open it if you don't have Borland C++ v4.5.

If you just want to look at the code, not work on it, then open the file "Tetris.cpp" in Notepad (or some simple text editor).  This will let you see the heart of the program, but you since you can't compile the code with a text editor, you can't play the game with any alterations you make.

If you have a different version of C++ which will not let you open the "Tetris.ide" project file, but you still wish to edit, compile, and/or run the code, then it is still possible to get this code going on your computer.

If you are using a DOS-based compiler than you should just be able to open the "Tetris.cpp" file and then work with it.

If you have a Windows-based compiler than this is where things can get a little tricky.  Since Windows does not support BGI drawing, you will have to make your own project file that will tell the compiler to make the executable a DOS-based program with BGI support.  Sounds complicated, but it's not that bad.

Granted, this will be different from compiler to compiler, but the same basic pattern will hold true.

  1. Open your compiler
  2. Click Project -> New Project
  3. Type in Tetris for the Project Path and Name  Make sure the path is the same path that the "Tetris.cpp" file is located.
  4. Change the Platform to DOS (Standard)
  5. Make sure BGI is checked under the Standard Libraries section
  6. Click OK
  7. Open the "Tetris.cpp" file and you're good to go!

What You've Been Waiting For

Now that you (should) know how to open the source code, here are the different versions:

[Bullet] Tetris v1.0.1:  This is a beta version for Tetris v1.1.  See Planned Updates for the changes underway.
[Bullet] Tetris v1.0 Source Code (13KB):  This is the first real version of my Tetris.  So, if you're planning to program Tetris for your end-of-the-year programming project, then this is the one for you!
[Bullet] Tetris v0.1 or maybe v0.5:  This was a beta version I found in which the file was called "Tetris v0.5" and inside the file, it was referred to as "Tetris v0.1".  I was going to post it up here, but after running it for a minute, and then checking the code, I soon realized that it was missing two of the pieces (the "L" and the "J").  But besides that, there were only subtle differences between that version and version 1.0 (like less customability, different colors for the pieces, etc).

Planned Updates

For those of you who want to see what's to come of this project in the near future, this is the place for you.

Tetris v1.1 (currently the beta Tetris v1.0.1):

[Bullet] Pressing down locks piece into place if piece cannot move down any further (DONE)
[Bullet] I dunno, I'll pick something from the list  :o)

Future Versions

These are the "big" projects that will define the next to come versions of Tetris

[Bullet] Add intro/exit screens
[Bullet] Give option to start game with height level (Random scattered blocks in specified height level and below)
[Bullet] Create two different game modes
[Bullet] Game Mode A is the traditional delete 10 lines and then get a level up
[Bullet] Game Mode B is where the player picks a level, then must delete 25 lines trying to get the highest possible score without losing
[Bullet] Add level increments
[Bullet] Make colors change at level up
[Bullet] Give option to start game at different level
[Bullet] Add some kind of indication of getting a Tetris (like a flash of light, and/or a sound)
[Bullet] Add a high score table

[Horizontal Rule]

This program was coded by

veGAMan infErior

on

Friday, October 20, 2000

and since then...

[a plethora of]

inferiors visited this page.

[Horizontal Rule]

Tell me what you think about the page.  Yes, I made this Matrix web theme, took all morning tell me how you like it.  If I don't get feedback, I don't update the page unless I am extremely bored...like today.  Here are some various ways of getting in contact with me.  I check my e-mail every day, I never plan to install ICQ again, I don't ever log into Yahoo Pager, I send mailing list info about once a month, I check my guest book twice a week.  I am open to suggestion.  Enough babbling.

E-mail:        veGAMan_infErior@yahoo.com
ICQ #:         19617229
Yahoo Pager:   veGAMan_infErior

Join my mailing list!
Enter your email address below,
then click the 'Join List' button:
Powered by ListBot

Sign My Guestbook
View My Guestbook
I got it for free at www.Lpage.com

My URL:  http://welcome.to/theinferior
I got it for free at http://welcome.to

[END TRANSMISSION]