TkTetris Tclet


Description

Tetris with multiplayer mode (Netris!). Requires Tcl/Tk 8.0+. Works either in Tk plugin or stand-alone with the same source code and full archive.

Options

For plugin, options are specified in the <embed> tag, like:
<embed src="tetris.tcl" width=480 height=560 blocksize=15>
For standalone, use the standard '-' notation, like:
tetris.tcl -blocksize 14
autopause TCL_BOOLEAN, Default: 0
Whether to use the auto-pause feature (pauses when game loses focus).
blocksize #, Default: 15 (pixels)
Size in pixels of one block. A tetris grid is 30 high X 10 wide.
color[0-6] colorname, Default: major colors
Color of each of the 7 different tetris pieces.
drop binding, Default: <Key-space>
Key binding to drop the piece all the way down.
left binding, Default: <Key-Left> (left arrow)
Key binding to move the piece left.
level #, Default: 0
Initial level to start at. I don't recommend starting above 18.
growing TCL_BOOLEAN, Default: 0
Whether to add rows while the user plays. This is done between pieces, to avoid disturbing play. Rows are added at intervals defined by growlevel.
growlevel #, Default: 0
Initial growing level to start at. This defines the speed at which rows would be added if growing is on. This is calculated as (maxinterval * (25 - growlevel)). This at level 0, rows would be added every 12.5 seconds, and at level 10, they are added every 7.5 seconds.
growmax #, Default: 26
Specifies the row level at which rows would no longer be added, should growing be on. This allows you to limit the growth activity. The Tetris board is 30 rows high.
maxinterval #, Default: 500 (microsecs)
Initial interval in microseconds between slides. This is decremented by maxint/20 every 10 rows (unless you start at a higher level), and should never go below 10 microsecs.
right binding, Default: <Key-Right> (right arrow)
Key binding to move the piece right.
rotleft binding, Default: <Key-Up> (up arrow)
Key binding to rotate the piece left (counterclockwise).
rotright binding, Default: <Key-Down> (down arrow)
Key binding to rotate the piece right (clockwise).
shadow TCL_BOOLEAN, Default: 1
Whether to use the shadow-piece feature (shadow at bottom)
shownext TCL_BOOLEAN, Default: 1
Whether to show the next piece
slide binding, Default: <Key-Return>
Key binding to slide the piece down one.
help/info
Displays usage info to stdout and exits

Multiplayer Options

multiplayer TCL_BOOLEAN, Default: 1
Whether to allow multiplayer mode (requires sockets)
highbandwidth TCL_BOOLEAN, Default: 1
Wether you have a high bandwidth connection to your opponent(s) More info will be shared if true. I recommend turning this off on Win/Mac because of slow game play.
hostname string, Default: [info hostname]
Hostname to use for yourself
port #, Default: 15141
TkTetris server port (that other TkTetris players would connect to).

Multiplayer Usage

In order to get the multiplayer option, sockets must be available (thus this is disabled for Tk plugin use). The play is as synchronized as possible between players. Any player can start or pause a game. See Multiplayer Rules for more info.

Connecting to Another Player

To connect to another player, you must know their hostname/IP and TkTetris port (default: 15141). You can find your own hostname/IP and port by opening the multiplayer dialog. When you have the other players vitals, ONLY ONE PLAYER should type in the info of the person to connect to in the proper entry fields on the multiplayer dialog and press Connect. The other player will receive a connection message. If the player accepts then you will see their name remain in your list of connected players. If they refuse then they will disappear from the listbox. Disconnect disconnects from all connected players.

Rules and Scoring

Each dropped piece is 5 points. Each row dropped rows is:
( NUMBER_ROWS_DROPPED ^^ 2 ) * ( CURRENT_LEVEL + 1 )
That means dropping multiple rows at a time is best. The level increases every 10 rows dropped. At this time the slide interval decreases (the game gets faster). The game is over when a new piece cannot be placed on the board.

Multiplayer Rules

Scoring occurs the same, but game play is slightly different. When a player drops more than one row, an equal number of rows is added to his opponents' board(s). When the game would normally be over for a player, his screen is instead reset and the game continues. That player also incurs a death, which accumulates. You can see other players' death count below the scale bar which pops up for that player. What is the scale bar? That indicates the height of the pieces on the other player's board. This is updated after each cemented piece in high bandwidth mode, but only after a row drops in low bandwidth mode. Reset also registers as a death and the game continues for that player. There is no Game Over, the game continues on with only the ability to pause.

Further Notes

Multiple rotates will move the piece to the left or up, a slight bug. However, I'm afraid the calculations to avoid this problem would cause the game to slow too much at high levels.

For those unable to find a willing competitor, the growing option can provide a good challenge. Also in the stand-alone version there is a dialog for preset game types for further challenging combinations.

Jeff Hobbs (jeff at hobbs org)