Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VBScript

Brick 2005 Game Engine (formerly Tetris 2005 Game Engine)

3.65/5 (15 votes)
16 Nov 2012CPOL9 min read 1   2.2K  
A Game engine tutorial describes how to play the game and how to customize the game. The game is user friendly that lets you to change the view, difficulty, etc. without changing the VB code.
Sample Image - Main.gif

Table of Contents

Introduction: What is Tetris '2005?

Tetris '2005 is an exciting action game. Throughout the game, bricks of various types fall from the top to the bottom of the playing area. When the bricks form a solid row of blocks across the playing area, that row vanishes.

Because this is the only way to remove blocks, you should try to form solid rows whenever possible. The game ends when the pieces stack up to the top of the playing area.

You can manipulate a brick only when it is falling. Falling pieces may be rotated, moved horizontally, or dropped to the bottom of the playing area.

This nice and small game offers High score lists, Preview Screen, Position Pointer and more. It has no multimedia but is intended to bring a taste of fun to a small break on a long, hard working day. However, if you would like to support my work, please rate this article and visit one of my other programs.
Check them out!

User's Manual

I realize that a number of people will just want to try out the sample and see if it is worth spending the time looking at the source code. So I will first present the game, the controls, then I will explain how it works in later sections.

This intermediate tutorial describes how to play Tetris and how to move Bricks.

The Bricks

Image 2The "." brick
Image 3 The ":" brick
Image 4 The "H" brick
Image 5 The "I" brick
Image 6 The "J" brick
Image 7 The "L" brick
Image 8 The "N" brick
Image 9 The "O" brick
Image 10 The "T" brick
Image 11 The "Z" brick

Rules of the Game

Bricks appear one at a time at the top of the playing area and then proceed to fall at a constant speed.

Each brick continues to fall until it lands on another brick or the bottom of the playing area.

You can manipulate a brick only when it is falling.

With the keyboard, you can rotate a falling brick and move it left, right, or down.

Each time there is a solid row of blocks across the playing area, that row vanishes. Try to manipulate the pieces as they fall so that solid rows form and disappear.

The game ends when the pieces are stacked to the top of the playing area.

Keyboard Functions

Image 12

Up Arrow,

Insert,

Home Rotates the current brick
Left Arrow Moves the current brick left
Right Arrow Moves the current brick right
Down Arrow, Drops the current brick to the bottom

Options

Image 13

[ ] Show preview screen

By unchecking this option, the preview box in which the upcoming brick is displayed, will be hidden. This results in special bonus points.

[ ] Show position pointer

By checking this option, RSM's Tetris 2005 will display a position pointer at the bottom of your "playground" to ease navigation of your pieces. Read the Scoring section for information about how this could influence your bonus points.

Skill Level

Here you can choose from which level to start playing. User can Select level according to their desire. Beginner for new user, Intermediate for Normal and Expert is suggested for advanced users.

Background Color

Click on the color preview area to change the background color of your RSM's Tetris 2005 "playground".

Playing the Game

The object of RSM's Tetris 2005 is to continue playing for as long as possible. The game is over when the playing area is stacked to the top with bricks. The following section explains how to play the game.

To Choose a Skill Level:

In the Options menu, choose a starting level from 1 to 20. The higher the level, the faster the pieces fall.

To Start a New Game:

From the buttons at the right, choose Start.

To Move a Brick Horizontally:

Image 14Image 15

Use the appropriate keyboard controls. You can move the current brick either left or right.
Note: If the current brick is close to the borders or close to already-positioned pieces, you may be unable to move it.

To Rotate a Brick:

Image 16

Use the appropriate keyboard controls. You can rotate the current brick 90 degrees counterclockwise.
Note: If the current brick is close to the borders or close to already-positioned pieces, you may be unable to rotate it.

To Drop a Brick:

Image 17

Use the appropriate keyboard controls. When you drop a brick, it falls rapidly until it lands on a stationary brick or the bottom of the playing area.

To Pause a Game:

From the Game menu, choose Pause, or Click Pause Button.

Note: To resume the game, choose Pause again.

Scoring

The current brick starts with an initial score value, which increases for each successive playing level.

The "Tetris '2005 Hall Of Shame"

Image 18

If you achieved a new High score (this means, if you achieved more points than the ones listed in the "RSM's Tetris 2005 Hall Of Shame" window), a special window opens and you can add your name and a "cool quote" of your choice to this list !

Image 19

You can also use the "Save" button to save your High score window to bitmap file named "HiScore.bmp".

Strategy and Hints

This section contains helpful hints for playing RSM's Tetris 2005 successfully.

  • Use the Brick Preview box to gain experience, and then turn this option off for higher scoring.
  • Experiment with the position pointer tool .. based on your reaction time, does it bring you more points than it costs ?
  • Avoid building "mountains." Try to keep the pile of pieces level at the top.
  • Avoid creating "canyons" that are one block wide and many blocks deep. You may find yourself nervously waiting for the long, skinny brick (which never seems to appear when you need it).
  • Always try to leave a "flat spot" at least three blocks wide along the top of the stacked pieces. This way you can drop most of the pieces without leaving any gaps.
  • Sometimes it is to your advantage to leave a gap and go on to the next level. If you can make the next level disappear, you may have time to fill the gap afterwards.
  • Once a brick lands on another brick, it can still be manipulated for a very short time. You can use this time to "slide" the brick under an "overhang."

Using the Code

Detailed comments can be found in the source archive.The game is built up from a number of smaller sub-systems. Each system provides a distinct purpose. I have identified the systems below.

Architecture

  • Game Engine
  • Main Window
    • Brick Display
    • Preview Screen
    • Position Pointer
    • 2D Button Display
  • Option Window
  • Score window
  • Help window

CORE ENGINE

The Tetris Core engine consists of the main four functions:

  • SelectBrick
  • SetCurrentPosition
  • DrawBrick
  • HideBrick

These functions provide support for brick related functions such as selecting a Brick, setting the current Position of the Brick, showing and hiding a Brick.

The core engine is implemented as a strict back-end engine. It has no user-interface components. Most of the functions return an Boolean return code. The return codes should always be examined to determine the completion status of these functions.

Special care has been taken to ensure that these functions are very stable and robust.

VB.NET
Public Sub SelectBrick()

This Subroutine is used to select Brick type.

VB.NET
Public Sub HideBrick(frm As Form)

This Subroutine is used to Hide all Bricks in the frm Form.

VB.NET
Public Sub DrawBlock(frm As Form)

This Subroutine is used to Show selected Brick in the frm Form.

VB.NET
Public Sub SetCurrentPosition(a As Integer, Optional b, _
	Optional c, Optional d, Optional e, Optional f)

This Subroutine is used to set initial position of Brick in the frm Form.

Other Functions of Importance

VB.NET
Public Sub Increment(X As Integer) 

This function is called when a user presses Left, Right or Down key from within the Main Window KeyDown Event. It increments the value of next position variables.

VB.NET
Public Sub CheckStatus(X As Integer, a As Integer, Optional b, _
	Optional c, Optional d) 

This function is called after Increment to check the availability of the position specified in next position variables.

VB.NET
Public Sub MoveBlock() 

If CheckStatus function returns true, then this function is called to move the current brick to the next position.

VB.NET
Public Sub CheckRowBuilt(frm As Form)

This function checks the status of each row and if any row is built, i.e., a row having 10 bricks, then removes that row and increases the score.

VB.NET
Public Function CheckGameOver(frm As Form) As Boolean 

This function is used to check the status of the game before drawing the new brick.

VB.NET
Public Sub frmOptionSetting() 

This function is used to change the game setting according to the setting user made using Option Window.

VB.NET
Public Sub LoadScoreFile(frm As Form) 

This function is used to Load score from the files to the Score Window.

VB.NET
Public Function CheckGameOver(frm As Form) As Boolean 

This function is used to Save score.

Preview Screen

The Preview Screen Module consists of the three functions:

VB.NET
Public Sub HidePicBox(frm As Form) 

This function is used to clear Preview Screen.

VB.NET
Public Sub ShowPicBox(frm As Form, a As Integer,Optional b, _
	Optional c, Optional d, Optional e,Optional f) 

This function is used to display Preview of next brick.

VB.NET
Public Sub ShowPreview(frm As Form) 

This function is used to set the position of the brick in the Preview window.

Position Pointer

The Position Pointer Module consists of the three functions:

VB.NET
Public Sub ShowPositionPointer(frm As Form) 

This function is used to display Position Pointer.

VB.NET
Public Sub HidePositionPointer(frm As Form) 

This function is used to Hide Position Pointer.

VB.NET
Public Sub SetPositionPointer() 

This function is used to set the Position of Position Pointer in Main Window.

2D Button Display

To display 2D button, we have to manipulate some of the Image box Mouse Events:

VB.NET
Private Sub imgbutton_MouseMove(Index As Integer, Button As Integer, _
	Shift As Integer, X As Single, Y As Single) 

In this Event, we draw rectangle with the help of Grey and White lines.

VB.NET
Private Sub imgbutton_MouseDown(Index As Integer, Button As Integer, _
	Shift As Integer, X As Single, Y As Single) 

In this Event, we change image box left and top Position.

VB.NET
Private Sub imgbutton_MouseUp(Index As Integer, Button As Integer, _
	Shift As Integer, X As Single, Y As Single) 

In this Event, we restore Image box left and top Position.

VB.NET
Private Sub imgbutton_DblClick(Index As Integer)

In this Event, we execute commands according to Image box index.

Option Window

Option Window gives the user the facility to configure the game setting according to their need.

Score Window

Score Window displays the detail list of users who achieved the highest score.

Help Window

Help Window displays Keyboard functions.

Conclusion

I would like to give credit and thanks to my brother Rohit Soam for constructive criticism & editing, and also to my friend Nikhil who helped me in testing the game.

History

Image 20

THE STORY

I started the whole thing by writing a small game including sources (based on Turbo C++). Since it has always been my (Mohit's) dream to create a logic game like this one, but I've never taken the time to even think about where to start with, I took the chance. We put ourselves together, added some nice features we knew people like you would like and here it is !

Everything we did on that game is just for our fun. It makes us happy to receive mails from you telling us if you like the game, why you like it (why you don't like it ... well, not sure ~'.'~ ) .

NOTE

RSM's Tetris 2005 is in no way affiliated with 'The Tetris Company' nor is it an official Tetris product. The Graphical Interface of Game is based on Bricks 2005 .

  • 8-Aug-2005 - Initial release of "RSM Tetris 1.1"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)