There are a lot of disadvantages, and the code is a lot of redundancy: D, lazy modification. The main purpose is to study the interface. I accidentally wrote a Russian square. In fact, it should be better to use abstract classes.
Document 1: BlockInterface.cs
Square interface.
Used to describe the behavior of the block and some attributes.
Using system;
Using system.drawing;
Namespace Blocks
{
///
/// Interface, provide a series of methods for providing block classes
///
Public Interface BlockInterface
{
///
/// square type
///
Int blockType
{
Get;
}
///
/// coordinate 1
///
Point P1
{
Get;
}
///
/// coordinate 2
///
Point P2
{
Get;
}
///
/// coordinate 3
///
Point P3
{
Get;
}
///
/// coordinate 4
///
Point P4
{
Get;
}
///
/// Draw block
///
Void Drawsel ();
///
/// Erase square
///
Void refresh ();
///
/// judgment if it can be moved
///
///
///
Bool Canmove (int VARTYPE);
///
/// Mobile block (left shift, right shift, down)
///
Void move (int VARTYPE);
///
/// Determine if it can be rotated
///
///
///
Bool cancircle ();
///
/// Rotate block (four different states)
///
Void circle ();
///
/// The square drops to the lowest point, fill the screen matrix
///
Void Fillmatrix ();
///
/ / / End of the game
///
///
Bool isover ();
}
}
Document 2: Common.cs
Some constants of some systems
Using system;
Using system.drawing;
Namespace Blocks
{
///
/// System utility constant class
///
Public Class Common
{
Private common ()
{
}
#Region draws constant
///
/// Draw a screen surface
///
Public Static Graphics DrawGraphics;
///
/// Black brush
///
Public static pen blackpen;
///
/// White brush
///
Public static pen whitepen;
///
/// red painting brush
///
Public static brush redbrush = brushes.red;
///
/// White painting brush
///
Public static brush whitebrush = brushes.white;
///
/// Rectangular width
///
Public static int width = 20;
///
/// rectangular height
///
Public static int Height = 20;
///
/// screen matrix
///
Public static int [,] matrix;
///
/// starting point
///
Public static point startpoint;
Public static blockinterface next;
///
/// initialization constant
///
Public Static Void SetCommon (Graphics G)
{
Blackpen = new pen (color.black, 2);
Whitepen = new pen (color.white, 2); matrix = new int [15, 20];
StartPoint = New Point (20, 0);
DrawGraphics = g;
Randomblock = new random ();
Next = block.createblock ();
}
#ndregion
#Region movement, state constant
///
/// Left shift
///
Public const INT LEFT = 1;
///
/// Right shift
///
Public const INT Right = 2;
///
/// drop
///
Public const INT Down = 3;
///
/// State 1
///
Public const stateone = 1;
///
/// State 2
///
Public const Int statetwo = 2;
///
/// State 3
///
Public const INTTHREE = 3;
///
/// State 4
///
Public const Int statefour = 4;
#ndregion
#Region graphic constant
///
/// straight
///
Public const Int blockne = 0;
///
/// L
///
Public const Int blocktwo = 1;
///
/// Reversed L
///
Public const Int blockthree = 2;
///
/// Ding
///
Public const Int blockfour = 3;
///
/// field
///
Public const Int blockfive = 4;
///
/// Z
///
Public const INT blocksix = 5;
///
/// Anti-Z
///
Public const Int blockseven = 6;
#ndregion
#REGION random variable
///
/// Random variable generator
///
Public Static Random RandombLock;
#ndregion
#Region statistical constant
///
/// speed
///
Public static int speed = 0;
///
/// Adjust speed constant
///
Public static int spetedConst = 10;
///
/// Score
///
Public static int score = 0;
#ndregion
}
}
Document 3: Block.cs
Square implementation
Using system;
Using system.drawing;
Namespace Blocks
{
///
/// Service class, responsible for the main task
///
Public Class Block
{
Private block ()
{
}
#Region randomly created blocks
///
/// Randomly create blocks
///
///
Public Static Blockinterface CreateBlock ()
{
Int results = common.randomblock.next (7);
Blockinterface iblock = NULL;
Blockinterface iblockreturn = NULL;
Switch (Result)
{
Case 0:
{
Iblock = new block ();
Break;
Case 1:
{
IBLOCK = New blocktwo ();
Break;
}
Case 2:
{
Iblock = new blockthree ();
Break;
}
Case 3:
{
Iblock = new blockfour ();
Break;
}
Case 4:
{
Iblock = new blockfive ();
Break;
}
Case 5:
{
IBLOCK = New blocksix ();
Break;
}
Case 6:
{
IBLOCK = New Blockseven ();
Break;
}
}
IF (Common.next! = NULL)
{
IBLOCKRETURN = Common.next;
Common.next = iblock;
}
Else
{
IBLOCKRETURN = IBLOCK;
}
Return Iblockreturn;
}
///
/// Draw the next block
///
///
Public Static Void DrawnextBlock (Graphics G)
{
g.clear (color.silver);
g.drawRectangle (Common.Blackpen, Common.Next.p1.x, Common.Next.p1.y, Common.Width, Common.Height);
g.FillRectangle (Common.Redbrush, Common.Next.p1.x, Common.Next.p1.y, Common.width, Common.Height);
g.drawRectangle (Common.Blackpen, Common.Next.p2.x, Common.Next.p2.y, Common.Width, Common.Height);
G.FillRectangle (Common.Redbrush, Common.Next.p2.x, Common.Next.p2.y, Common.width, Common.Height);
g.drawRectangle (Common.Blackpen, Common.Next.p3.x, Common.Next.p3.y, Common.Width, Common.Height);
g.fillRectangle (Common.Redbrush, Common.Next.p3.x, Common.Next.p3.y, Common.Width, Common.Height);
g.drawRectangle (Common.Blackpen, Common.Next.p4.x, Common.Next.p4.y, Common.width, Common.Height);
g.fillRectangle (Common.Redbrush, Common.Next.p4.x, Common.Next.p4.y, Common.Width, Common.Height);
}
#ndregion
#Region Clear full line
///
/// Remove full of rows
///
Public Static Void Collector ()
{
For (int i = 0; i <20; i )
{
BOOL FILLED = TRUE;
For (int J = 0; J <15; J )
{
IF (Common.Matrix [J, I] == 0)
{
Filled = false;
Break;
}
}
IF (Filled)
{
Common.score = 1; // Add score
Updatemartix (i);
}
}
Refresh ();
}
///
/// update matrix
///
///
Public Static void Updatemartix (int line)
{
For (int i = varline; i> = 0; I -)
{
For (int J = 0; J <15; J )
{
IF (i == 0)
{
Common.matrix [J, I] = 0;
}
Else
{
Common.matrix [J, I] = Common.matrix [J, I - 1];
}
}
}
}
///
/// Refresh screen
///
Public static void refresh ()
{
Common.drawgraphics.clear (color.white);
For (int i = 0; i <20; i )
{
For (int J = 0; J <15; J )
{
IF (Common.matrix [J, I] == 1)
{
Common.drawgraphics.drawRectangle (Common.Blackpen, J * 20, i * 20, common.width, common.height);
Common.drawgraphics.FillRectangle (Common.Redbrush, J * 20, i * 20, Common.width, Common.Height);
}
}
}
}
#ndregion
#REGION adjustment speed
///
/ / According to the score adjustment speed
///
///
Public static int getSpeed ()
{
IF (Common.Speed == 9)
{
Return 100;
}
Common.speed = common.score / common.speedconst;
Return (10 - Common.Speed) * 100;
}
#ndregion
#Region game end
///
/// game over
///
Public Static void GameOver ()
{
Common.speed = 0;
Common.score = 0;
Common.drawgraphics.clear (color.white);
CommON.drawgraphics.drawstring ("Game over!", New Font ("Song", 40), Brushes.black, New Pointf (30, 150));
}
#ndregion
#Region Basic Drawing Method
///
/// Draw block
///
///
///
///
///
Public Static Void DrawBlocks (Point Pointone, Point PointTtwo, Point Pointthree, Point Pointfour)
{
Common.drawgraphics.drawRectangle (Common.Blackpen, Pointone.x, Pointone.y, Common.width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Redbrush, Pointone.x, Pointone.y, Common.width, Common.Height);
Common.drawgraphics.drawRectangle (Common.Blackpen, PointTwo.x, PointTwo.y, Common.Width, Common.Height);
Common.DrawGraphics.FillRectangle (Common.RedBrush, PointTwo.X, PointTwo.Y, Common.Width, Common.Height); Common.DrawGraphics.DrawRectangle (Common.BlackPen, PointThree.X, PointThree.Y, Common.Width, Common .Height);
Common.drawgraphics.FillRectangle (Common.Redbrush, Pointthree.x, Pointthree.y, Common.width, Common.Height);
Common.drawgraphics.drawRectangle (Common.Blackpen, PointFour.x, Pointfour.y, Common.Width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Redbrush, Pointfour.x, Pointfour.y, Common.Width, Common.Height);
}
///
/// Remove the square
///
///
///
///
///
Public Static Void RemoveBlocks (Point Pointone, Point PointTtwo, Point Pointthree, Point Pointfour)
{
Common.drawgraphics.drawRectangle (Common.Whitepen, Pointone.x, Pointone.y, Common.Width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Whitebrush, Pointone.x, Pointone.y, Common.Width, Common.Height);
Common.drawgraphics.drawRectangle (Common.Whitepen, PointTwo.x, PointTwo.y, Common.Width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Whitebrush, PointTwo.x, PointTwo.y, Common.width, Common.Height);
Common.drawgraphics.drawRectangle (Common.Whitepen, Pointthree.x, Pointthree.y, Common.width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Whitebrush, Pointthree.x, Pointthree.y, Common.width, Common.Height);
Common.drawgraphics.drawRectangle (Common.Whitepen, Pointfour.x, Pointfour.y, Common.Width, Common.Height);
Common.drawgraphics.FillRectangle (Common.Whitebrush, PointFour.x, Pointfour.y, Common.width, Common.Height);
}
#ndregion
}
#Region square 1: Straight stick
Public Class Blockone: BlockInterface
{
///
/// Constructor
///
Public blockone ()
{
Pointone = common.startpoint;
PointTwo = New Point (Pointone.x Common.width, Pointone.y);
Pointthree = New Point (PointTwo.x Common.width, Pointone.y); PointFour = New Point (PointThree.x Common.width, Pointone.y);
Current = Common.StateOne;
}
#Region private variable
Private int current;
PRIVATE POINT POINTONE;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return Common.blockone;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
Case Common.Left:
{
IF (PointOne.x == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOndone.x / 20 - 1, Pointone.y / 20] == 1 || Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 || Common. Matrix [PointThree.x / 20 -1, Pointthree.y / 20] == 1 || Common.matrix [PointFour.x / 20 -1, PointFour.y / 20] == 1)
{
Return False;
}
}
Break;
}
Case Common.right:
{
IF (this.current == Common.Stateone || this.current == Common.Statethree) // Straight strip is horizontal
{
IF (PointFour.x == 280)
{
Return False;
}
Else
{
IF (Common.Matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
}
Else
{
IF (PointFour.x == 280)
{
Return False;
}
}
Break;
}
Case Common.down:
{
IF (this.current == Common.Stateone || this.current == Common.Statethree) {
IF (Pointone.Y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [Pointone.x / 20, PointOne.y / 20 1] == 1 || Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 || Common. Matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 || Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
Else
{
IF (Pointfour.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointFour.x / 20, Pointfour.y / 20 1] == 1)
{
Return False;
}
}
}
Break;
}
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
Switch (VARTYPE)
{
Case Common.Left:
{
THIS.REFRESH ();
PointOne.x - = common.width;
PointTwo.x - = Common.width;
Pointthree.x - = common.width;
Pointfour.x - = Common.width;
THIS.DRAWSELF ();
Break;
}
Case Common.right:
{
THIS.REFRESH ();
PointOne.x = Common.width;
PointTwo.x = Common.width;
PointThree.x = Common.width;
PointFour.x = Common.width;
THIS.DRAWSELF ();
Break;
}
Case Common.down:
{
THIS.REFRESH ();
Pointone.y = Common.Height;
PointTwo.y = Common.Height;
Pointthree.y = Common.Height;
Pointfour.y = Common.Height;
THIS.DRAWSELF ();
Break;
}
}
}
Public bool cancircle ()
{
IF (this.current == Common.Stateone)
{
IF (Pointone.Y <60)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, (Pointone.y - 60) / 20] == 1 ||
Common.matrix [PointOne.x / 20, (Pointone.y - 40) / 20] == 1 ||
Common.matrix [PointOne.x / 20, (PointOne.y - 20) / 20] == 1 ||
Common.matrix [(Pointone.x 20) / 20, (Pointone.y - 60) / 20] == 1 || Common.matrix [(Pointone.x 20) / 20, (PointOne.y - 40) / 20] == 1 ||
Common.matrix [(Pointone.x 20) / 20 (PointOne.y - 20) / 20] == 1 ||
Common.matrix [(PointOne.x 40) / 20 (Pointone.y - 60) / 20] == 1 ||
Common.matrix [(PointOne.x 40) / 20 (Pointone.y - 40) / 20] == 1 ||
Common.matrix [(PointOne.x 40) / 20, (Pointone.y - 20) / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateTwo)
{
IF (Pointone.x <40 || PointOne.x> 260)
{
Return False;
}
Else
{
IF (Common.Matrix [(Pointone.x - 40) /20 ,PointOne.y/20] == 1 ||
Common.matrix [(PointOne.x - 20) /20 ,Pointone.Y/20] == 1 ||
Common.matrix [(PointOne.x - 40) / 20 (Pointone.y 20) / 20] == 1 ||
Common.matrix [(PointOne.x - 20) / 20, (Pointone.y 20) / 20] == 1 ||
Common.matrix [(Pointone.x - 40) / 20, (Pointone.y 40) / 20] == 1 ||
Common.matrix [(PointOne.x - 20) / 20, (Pointone.y 40) / 20] == 1 ||
Common.matrix [(PointOne.x - 40) / 20, (Pointone.y 60) / 20] == 1 ||
Common.matrix [(PointOne.x - 20) / 20, (Pointone.y 60) / 20] == 1 ||
Common.matrix [(PointOne.x 20) / 20, (Pointone.y 60) / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (Common.Matrix [PointTwo.x / 20, (PointTwo.y - 60) / 20] == 1 ||
Common.matrix [(PointTwo.x 20) / 20, (PointTwo.y - 60) / 20] == 1 ||
Common.matrix [(PointTwo.x 40) / 20, (PointTwo.y - 60) / 20] == 1 ||
Common.matrix [PointTwo.x / 20, (PointTwo.y - 40) / 20] == 1 ||
Common.matrix [(PointTwo.x 20) / 20, (PointTwo.y - 40) / 20] == 1 ||
Common.matrix [(PointTwo.x 40) / 20, (PointTwo.y - 40) / 20] == 1 ||
Common.matrix [PointTwo.x / 20, (PointTwo.y - 20) / 20] == 1 ||
Common.matrix [(PointTwo.x 20) / 20, (PointTwo.y - 20) / 20] == 1 ||
Common.matrix [(PointTwo.x 40) / 20, (PointTwo.y - 20) / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Pointone.x> 240 || PointOne.x == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [(PointFour.x - 20) /20 ,pointfour.y/20] == 1 ||
Common.matrix [(PointFour.x 20) /20 ,pointfour.y/20] == 1 ||
Common.matrix [(PointFour.x 40) /20 ,pointfour.y/20] == 1 ||
Common.matrix [(PointOne.x 40) /20 ,PointOne.y/20] == 1 ||
Common.matrix [(PointOne.x 20) /20 ,PointOne.y/20] == 1 ||
Common.matrix [(Pointone.x 40) / 20, (Pointone.y 20) / 20] == 1 ||
Common.matrix [(PointOne.x 20) / 20, (Pointone.y 20) / 20] == 1 ||
Common.matrix [(Pointone.x 40) / 20, (Pointone.y 40) / 20] == 1 ||
Common.matrix [(PointOne.x 20) / 20, (Pointone.y 40) / 20] == 1)
{
Return False;
}
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone)
{
PointOne.x = 40;
PointOne.y - = 60;
PointTwo.x = 20;
PointTwo.y - = 40;
Pointthree.y - = 20;
Pointfour.x - = 20;
THIS.CURRENT = Common.StateTwo;
THIS.DRAWSELF ();
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.x - = 40;
PointOne.y = 60;
PointTwo.x - = 20;
PointTwo.y = 40;
Pointthree.y = 20;
PointFour.x = 20;
THIS.CURRENT = Common.Statethree; this.drawself ();
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.x = 20;
PointOne.y - = 60;
PointTwo.y - = 40;
PointThree.x - = 20;
Pointthree.y - = 20;
Pointfour.x - = 40;
This.current = Common.statefour;
THIS.DRAWSELF ();
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.x - = 20;
PointOne.y = 60;
PointTwo.y = 40;
PointThree.x = 20;
Pointthree.y = 20;
Pointfour.x = 40;
THIS.CURRENT = Common.Stateone;
THIS.DRAWSELF ();
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (Common.Matrix [common.startpoint.x / 20, common.startpoint.y / 20] == 1 ||
Common.matrix [(Common.StartPoint.x 20) /20, Common.StartPoint.Y/20] == 1 ||
Common.matrix [(Common.StartPoint.x 40) /20, Common.StartPoint.Y/20] == 1 ||
Common.matrix [(Common.StartPoint.x 60) /20, Common.StartPoint.Y/20] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region square 2: L
Public Class Blocktwo: BlockInterface
{
///
/// Constructor
///
Public blocktwo ()
{
Pointone = common.startpoint;
PointTWO = New Point (Pointone.x, PointOne.y Common.Height);
Pointthree = New Point (PointTwo.x, PointTwo.y Common.Height);
Pointfour = New Point (PointThree.x Common.width, Pointthree.);
Current = Common.StateOne;
}
#Region private variable
Private int current;
PRIVATE POINT POINTONE; Private Point PointTwo;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return common.blocktwo;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
#Region left shift
Case Common.Left:
{
IF (this.current == Common.Stateone)
{
IF (Pointone.x <= 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (Pointone.x <= 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 -1, Pointone.y / 20] == 1 ||
Common.matrix [Pointfour.x / 20 -1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (PointFour.x <= 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Pointone.x <= 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 - 1, PointOne.y / 20] == 1 || Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#Region right shift
Case Common.right:
{
IF (this.current == Common.Stateone)
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (PointOne.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#region down
Case Common.down:
{
IF (this.current == Common.Stateone)
{
IF (Pointfour.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateTwo) {
IF (PointThree.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (Pointone.Y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.Statefour)
{
IF (Pointone.Y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
Break;
}
#ndregion
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = common.width;
PointTwo.x - = Common.width;
Pointthree.x - = common.width;
Pointfour.x - = Common.width;
Break;
}
Case Common.right:
{
PointOne.x = Common.width;
PointTwo.x = Common.width;
PointThree.x = Common.width;
PointFour.x = Common.width;
Break;
}
Case Common.down:
{
Pointone.y = Common.Height;
PointTwo.y = Common.Height;
Pointthree.y = Common.Height;
Pointfour.y = Common.Height;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle ()
{
IF (this.current == Common.Stateone)
{
IF (Pointone.x <20 || pointfour.y == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 - 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateTwo)
{
IF (Pointone.Y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (PointOne.x> = 280)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.Statefour)
{
IF (PointOne.y == 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 - 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 - 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 - 1] == 1)
{
Return False;
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone) {
PointOne.x - = 20;
PointOne.y = 40;
PointTwo.y = 20;
PointThree.x = 20;
Pointfour.y - = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.StateTwo;
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.x = 40;
PointOne.y = 20;
PointTwo.x = 20;
Pointthree.y - = 20;
Pointfour.x - = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Statethree;
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.x - = 20;
PointOne.y - = 20;
PointTwo.x - = 20;
PointTwo.y - = 20;
Pointfour.x = 40;
THIS.DRAWSELF ();
This.current = Common.statefour;
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.y - = 40;
PointThree.x - = 20;
Pointthree.y = 20;
Pointfour.x - = 20;
Pointfour.y = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Stateone;
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (common.matrix [common.startpoint.x /20,common.startpoint.y/20] == 1 ||
Common.matrix [common.startpoint.x /20 ,common.startpoint.y/20 1] == 1 ||
Common.matrix [common.startpoint.x /20 ,common.startpoint.y/20 2] == 1 ||
Common.matrix [common.startpoint.x / 20 1, common.startpoint.y / 20 2] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region square three: counter-write L
Public Class Blockthree: BlockInterface
{
////// Constructor
///
Public blockthree ()
{
Pointfour = Common.startPoint;
Pointthree = New Point (Pointfour.x, Pointfour.y Common.Height);
PointTWO = New Point (PointThree.x, Pointthree.y Common.Height);
Pointone = New Point (PointTwo.x - Common.width, PointTwo.y);
Current = Common.StateOne;
}
#Region private variable
Private int current;
PRIVATE POINT POINTONE;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return Common.blockthree;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
#Region left shift
Case Common.Left:
{
IF (Pointone.x <20)
{
Return False;
}
IF (this.current == Common.Stateone)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 || Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#Region right shift
Case Common.right:
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (this.current == Common.Stateone)
{
IF (Common.Matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (Common.Matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (Common.Matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Common.Matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#region down
Case Common.down:
{
IF (this.current == Common.Stateone)
{
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1) {
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (PointTwo.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointFour.x / 20, PointFour.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Pointfour.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointFour.x / 20, PointFour.y / 20 1] == 1 ||
Common.matrix [PointOne.x / 20, PointOne.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1)
{
Return False;
}
}
Break;
}
#ndregion
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = common.width;
PointTwo.x - = Common.width;
Pointthree.x - = common.width;
Pointfour.x - = Common.width;
Break;
}
Case Common.right:
{
PointOne.x = Common.width;
PointTwo.x = Common.width;
PointThree.x = Common.width;
PointFour.x = Common.width;
Break;
}
Case Common.down:
{
Pointone.y = Common.Height;
PointTwo.y = Common.Height;
Pointthree.y = Common.Height;
Pointfour.y = Common.Height;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle () {
IF (this.current == Common.Stateone)
{
IF (PointTwo.x> = 280 || PointOne.y == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointOne.x / 20, Pointone.y / 20 - 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateTwo)
{
IF (PointTwo.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 1] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (Pointone.x <20)
{
Return False;
}
Else
{
IF (Common.Matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1 ||
Common.matrix [Pointone.x / 20 - 1, PointOne.y / 20] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.Statefour)
{
IF (PointOne.y == 0)
{
Return False;
}
IF (Common.Matrix [PointTwo.x / 20, PointTwo.y / 20 - 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 - 1] == 1 ||
Common.matrix [Pointone.x / 20, Pointone.y / 20 - 1] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone) {
PointOne.y - = 20;
PointTwo.x - = 20;
Pointthree.y = 20;
PointFour.x = 20;
Pointfour.y = 40;
THIS.CURRENT = Common.StateTwo;
THIS.DRAWSELF ();
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.y = 40;
PointThree.x - = 20;
Pointthree.y - = 20;
Pointfour.x - = 20;
Pointfour.y - = 20;
THIS.CURRENT = Common.Statethree;
THIS.DRAWSELF ();
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.x - = 20;
PointOne.y - = 40;
PointTwo.y - = 20;
PointThree.x = 20;
Pointfour.y = 20;
This.current = Common.statefour;
THIS.DRAWSELF ();
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.x = 20;
PointOne.y = 20;
PointTwo.x = 20;
PointTwo.y = 20;
Pointfour.y - = 40;
THIS.CURRENT = Common.Stateone;
THIS.DRAWSELF ();
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (common.matrix [common.startpoint.x /20,common.startpoint.y/20] == 1 ||
Common.matrix [common.startpoint.x /20 ,common.startpoint.y/20 1] == 1 ||
Common.matrix [common.startpoint.x /20 ,common.startpoint.y/20 2] == 1 ||
Common.matrix [common.startpoint.x / 20 - 1, common.startpoint.y / 20 2] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region square four: Ding
Public Class Blockfour: BlockInterface
{
///
/// Constructor
///
Public blockfour ()
{
Pointfour = Common.startPoint;
Pointthree = New Point (Pointfour.x Common.width, Pointfour.y Common.Height);
PointTwo = New Point (Pointfour.x, Pointfour.y Common.Height);
Pointone = New Point (Pointfour.x - Common.width, Pointfour.y Common.Height);
Current = Common.StateOne;
}
#Region private variable
Private int current;
PRIVATE POINT POINTONE;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return Common.blockfour;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
#Region left shift
Case Common.Left:
{
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (Pointone.x <20)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 -1, Pointone.y / 20] == 1 ||
Common.matrix [Pointfour.x / 20 -1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (Pointone.x <20)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 -1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 -1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 -1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour) {
IF (PointFour.x <20)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 -1, Pointone.y / 20] == 1 ||
Common.matrix [Pointfour.x / 20 -1, Pointfour.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 -1, Pointthree.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#Region right shift
Case Common.right:
{
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (PointTHree.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (PointTHree.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#region down
Case Common.down:
{
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (PointThree.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Stateone) {
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (Pointfour.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1)
{
Return False;
}
}
Break;
}
#ndregion
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = common.width;
PointTwo.x - = Common.width;
Pointthree.x - = common.width;
Pointfour.x - = Common.width;
Break;
}
Case Common.right:
{
PointOne.x = Common.width;
PointTwo.x = Common.width;
PointThree.x = Common.width;
PointFour.x = Common.width;
Break;
}
Case Common.down:
{
Pointone.y = Common.Height;
PointTwo.y = Common.Height;
Pointthree.y = Common.Height;
Pointfour.y = Common.Height;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle ()
{
IF (this.current == Common.Stateone)
{
IF (PointOne.y> = 380 || Pointone.y == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 - 1] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateTwo)
{
IF (Pointone.x <20)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (PointOne.y == 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [Pointone.x / 20, Pointone.y / 20 - 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (PointOne.x> = 280 || PointOne.x == 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone)
{
PointOne.x = 20;
PointOne.y - = 20;
PointThree.x - = 20;
Pointthree.y = 20;
PointFour.x = 20;
Pointfour.y = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.StateTwo;
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.x - = 20; PointOne.y = 20;
PointThree.x = 20;
Pointthree.y - = 20;
Pointfour.y = 20;
Pointfour.x - = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Statethree;
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.x = 20;
PointOne.y - = 20;
PointThree.x - = 20;
Pointthree.y = 20;
Pointfour.x - = 20;
Pointfour.y - = 20;
THIS.DRAWSELF ();
This.current = Common.statefour;
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.x - = 20;
PointOne.y = 20;
PointThree.x = 20;
Pointthree.y - = 20;
PointFour.x = 20;
Pointfour.y - = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Stateone;
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (common.matrix [common.startpoint.x /20,common.startpoint.y/20] == 1 ||
Common.matrix [common.startpoint.x /20 ,common.startpoint.y/20 1] == 1 ||
Common.matrix [Common.StartPoint.x / 20 1, Common.StartPoint.y / 20 1] == 1 ||
Common.matrix [common.startpoint.x / 20 - 1, common.startpoint.y / 20 1] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region square five: field
Public Class BlockFive: BlockInterface
{
///
/// Constructor
///
Public BlockFive ()
{
Pointone = common.startpoint;
PointTWO = New Point (Common.StartPoint.x 20, Common.StartPoint.y);
Pointthree = new point (common.startpoint.x, common.startpoint.y 20); pointfour = new point (common.startpoint.x 20, common.startpoint.y 20);
Current = Common.StateOne;
}
#Region private variable
Private int current = common.stateOc
PRIVATE POINT POINTONE;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return Common.blockFive;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
Case Common.Left:
{
IF (Pointone.x <= 0)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 - 1, PointOne.y / 20] == 1 || Common.matrix [PointTHree.x / 20 - 1, Pointone.y / 20] == 1)
{
Return False;
}
}
Break;
}
Case Common.right:
{
IF (PointTwo.x> = 280)
{
Return False;
}
Else
{
IF (Common.Matrix [PointTwo.x / 20 1, PointOne.y / 20] == 1 || Common.matrix [PointFour.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
Break;
}
Case Common.down:
{
IF (PointThree.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 || Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
Break;
}
}
Return True;
}
Public void move (int VARTYPE) {
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = 20;
PointTwo.x - = 20;
PointThree.x - = 20;
Pointfour.x - = 20;
Break;
}
Case Common.right:
{
PointOne.x = 20;
PointTwo.x = 20;
PointThree.x = 20;
PointFour.x = 20;
Break;
}
Case Common.down:
{
PointOne.y = 20;
PointTwo.y = 20;
Pointthree.y = 20;
Pointfour.y = 20;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle ()
{
Return True;
}
Public void circle ()
{
Return;
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (Common.Matrix [common.startpoint.x / 20, common.startpoint.y / 20] == 1 ||
Common.matrix [common.startpoint.x / 20 1, common.startpoint.y / 20] == 1 ||
Common.matrix [Common.StartPoint.x / 20 1, Common.StartPoint.y / 20 1] == 1 ||
Common.matrix [common.startpoint.x / 20, common.startpoint.y / 20 1] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region Square Six: Z
Public Class Blocksix: BlockInterface
{
///
/// Constructor
///
Public blocksix ()
{
Pointone = common.startpoint;
PointTWO = New Point (Common.StartPoint.x 20, Common.StartPoint.y);
Pointthree = New Point (PointTwo.x, PointTwo.y 20);
PointFour = New Point (PointThree.x 20, PointThree.y);
Current = Common.StateOne;
}
#Region private variable
Private int current = common.stateone; private point point;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return Common.blocksix;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
#Region left shift
Case Common.Left:
{
IF (Pointone.x <20)
{
Return False;
}
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#Region right shift
Case Common.right:
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (Common.Matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour) {
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#region down
Case Common.down:
{
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (PointThree.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1)
{
Return False;
}
}
Break;
}
#ndregion
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = 20;
PointTwo.x - = 20;
PointThree.x - = 20;
Pointfour.x - = 20;
Break;
}
Case Common.right:
{
PointOne.x = 20;
PointTwo.x = 20;
PointThree.x = 20;
PointFour.x = 20;
Break;
}
Case Common.down:
{
PointOne.y = 20;
PointTwo.y = 20;
Pointthree.y = 20;
Pointfour.y = 20;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle ()
{
IF (this.current == Common.Stateone)
{
IF (Pointone.y == 0) {
Return False;
}
IF (Common.Matrix [PointOne.x / 20, PointOne.y / 20 -1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 -1] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20 -1] == 1 ||
Common.matrix [PointOne.x / 20 1, Pointone.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (PointFour.x> = 280)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 2, PointTwo.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
}
IF (this.current == Common.StateThree)
{
IF (PointThree.y> = 380)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointOne.x / 20, PointOne.y / 20 2] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
}
IF (this.current == Common.Statefour)
{
IF (Pointone.x <20)
{
Return False;
}
Else
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [Pointfour.x / 20 - 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 2, PointFour.y / 20] == 1)
{
Return False;
}
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone)
{
PointOne.x = 20;
PointOne.y = 20;
Pointthree.x = 20; pointthree.y - = 20;
Pointfour.y - = 40;
THIS.DRAWSELF ();
THIS.CURRENT = Common.StateTwo;
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.y - = 20;
PointTwo.x = 20;
Pointthree.y = 20;
PointFour.x = 20;
Pointfour.y = 40;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Statethree;
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.y = 40;
PointTwo.x - = 20;
PointTwo.y = 20;
Pointfour.x - = 20;
Pointfour.y - = 20;
THIS.DRAWSELF ();
This.current = Common.statefour;
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.x - = 20;
PointOne.y - = 40;
PointTwo.y - = 20;
PointThree.x - = 20;
Pointfour.y = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Stateone;
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (Common.Matrix [common.startpoint.x / 20, common.startpoint.y / 20] == 1 ||
Common.matrix [common.startpoint.x / 20 1, common.startpoint.y / 20] == 1 ||
Common.matrix [Common.StartPoint.x / 20 1, Common.StartPoint.y / 20 1] == 1 ||
Common.matrix [common.startpoint.x / 20 2, common.startpoint.y / 20 1] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion
}
#ndregion
#Region block seven: Anti-Z
Public Class Blockseven: BlockInterface
{
///
/// Constructor
///
Public blockseven ()
{
Pointthree = Common.startPoint;
PointFour = New Point (Common.StartPoint.x 20, Common.StartPoint.y); Pointone = New Point (PointThree.x - 20, PointThree.y 20);
PointTWO = New Point (PointThree.x, Pointthree.y 20);
Current = Common.StateOne;
}
#Region private variable
Private int current = common.stateOc
PRIVATE POINT POINTONE;
PRIVATE POINT POINTTWO;
PRIVATE POINT POINTTHREE
PRIVATE POINT POINTFOUR;
#ndregion
#Region coordinate properties
Public Point P1
{
get
{
Return this.PointOn
}
}
Public Point P2
{
get
{
Return this.PointTwo;
}
}
PUBLIC POINT P3
{
get
{
Return this.Pointthree;
}
}
PUBLIC POINT P4
{
get
{
Return this.Pointfour;
}
}
#ndregion
#Region blockInterface member
Public int blockType
{
get
{
Return common.blockseven;
}
}
Public void drawself ()
{
Block.drawblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public void refresh ()
{
Block.removeblocks (Pointone, PointTwo, Pointthree, Pointfour);
}
Public Bool Canmove (int VARTYPE)
{
Switch (VARTYPE)
{
#Region left shift
Case Common.Left:
{
IF (Pointone.x <20)
{
Return False;
}
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 - 1, Pointthree.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#Region right shift
Case Common.right:
{
IF (PointFour.x> = 280)
{
Return False;
}
IF (this.current == Common.Stateone || this.current == Common.Statethree) {
IF (Common.Matrix [PointTwo.x / 20 1, PointTwo.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
Break;
}
#ndregion
#region down
Case Common.down:
{
IF (this.current == Common.Stateone || this.current == Common.StateThree)
{
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Statetwo || this.current == Common.StateFour)
{
IF (Pointfour.y> = 380)
{
Return False;
}
IF (Common.Matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, PointFour.y / 20 1] == 1)
{
Return False;
}
}
Break;
}
#ndregion
}
Return True;
}
Public Void Move (int VARTYPE)
{
IF (! this.canmove (varType))
{
Return;
}
THIS.REFRESH ();
Switch (VARTYPE)
{
Case Common.Left:
{
PointOne.x - = 20;
PointTwo.x - = 20;
PointThree.x - = 20;
Pointfour.x - = 20;
Break;
}
Case Common.right:
{
PointOne.x = 20;
PointTwo.x = 20;
PointThree.x = 20;
PointFour.x = 20;
Break;
}
Case Common.down: {
PointOne.y = 20;
PointTwo.y = 20;
Pointthree.y = 20;
Pointfour.y = 20;
Break;
}
}
THIS.DRAWSELF ();
}
Public bool cancircle ()
{
IF (this.current == Common.Stateone)
{
IF (Pointone.Y> = 380)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 1] == 1 ||
Common.matrix [PointTwo.x / 20, PointTwo.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 2] == 1)
{
Return False;
}
}
IF (this.current == Common.StateTwo)
{
IF (PointTHree.x> = 280)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 1, Pointone.y / 20] == 1 ||
Common.matrix [PointOne.x / 20 2, PointOne.y / 20] == 1 ||
Common.matrix [PointThree.x / 20 1, PointThree.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 1, Pointfour.y / 20] == 1)
{
Return False;
}
}
IF (this.current == Common.StateThree)
{
IF (PointOne.y == 0)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20, Pointone.y / 20 - 1] == 1 ||
Common.matrix [PointOne.x / 20, Pointone.y / 20 - 2] == 1 ||
Common.matrix [PointThree.x / 20, Pointthree.y / 20 - 1] == 1 ||
Common.matrix [PointFour.x / 20, Pointfour.y / 20 - 1] == 1)
{
Return False;
}
}
IF (this.current == Common.Statefour)
{
IF (Pointone.x <20)
{
Return False;
}
IF (Common.Matrix [PointOne.x / 20 - 1, Pointone.y / 20] == 1 ||
Common.matrix [PointTwo.x / 20 - 1, PointTwo.y / 20] == 1 ||
Common.matrix [Pointfour.x / 20 - 1, Pointfour.y / 20] == 1 ||
Common.matrix [PointFour.x / 20 - 2, PointFour.y / 20] == 1)
{
Return False;
}
}
Return True;
}
Public void circle ()
{
IF (! this.cancircle ())
{
Return;
}
THIS.REFRESH ();
IF (this.current == Common.Stateone)
{
PointOne.x = 20;
PointOne.y - = 20;
PointThree.x = 20;
Pointthree.y = 20;
Pointfour.y = 40;
THIS.DRAWSELF ();
THIS.CURRENT = Common.StateTwo;
Return;
}
IF (this.current == Common.StateTwo)
{
PointOne.y = 20;
PointTwo.x = 20;
Pointthree.y - = 20;
PointFour.x = 20;
Pointfour.y - = 40;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Statethree;
Return;
}
IF (this.current == Common.StateThree)
{
PointOne.y - = 40;
PointTwo.x - = 20;
PointTwo.y - = 20;
Pointfour.x - = 20;
Pointfour.y = 20;
THIS.DRAWSELF ();
This.current = Common.statefour;
Return;
}
IF (this.current == Common.Statefour)
{
PointOne.x - = 20;
PointOne.y = 40;
PointTwo.y = 20;
PointThree.x - = 20;
Pointfour.y - = 20;
THIS.DRAWSELF ();
THIS.CURRENT = Common.Stateone;
Return;
}
}
Public void fillmatrix ()
{
Common.matrix [PointOne.x / 20, Pointone.y / 20] = 1;
Common.matrix [PointTwo.x / 20, PointTwo.y / 20] = 1;
Common.matrix [PointThree.x / 20, Pointthree.y / 20] = 1;
Common.matrix [PointFour.x / 20, Pointfour.y / 20] = 1;
}
Public bool isover ()
{
IF (Common.Matrix [common.startpoint.x / 20, common.startpoint.y / 20] == 1 ||
Common.matrix [common.startpoint.x / 20, common.startpoint.y / 20 1] == 1 ||
Common.matrix [Common.StartPoint.x / 20 - 1, Common.StartPoint.y / 20 1] == 1 ||
Common.matrix [common.startpoint.x / 20 1, common.startpoint.y / 20] == 1)
{
THIS.DRAWSELF ();
Return True;
}
Return False;
}
#ndregion}
#ndregion
}
Document 4: mainform.cs
Form
Using system;
Using system.drawing;
Using system.collections;
Using system.componentmodel;
Using system.windows.forms;
Using system.data;
Namespace Blocks
{
///
/// Form1 summary description.
///
Public Class Mainform: System.Windows.Forms.form
{
Private system.windows.Forms.Panel Panel1;
Private system.windows.forms.timer Timer1;
Private system.componentmodel.icontainer components;
Private system.windows.Forms.mainMenu mainmentu1;
Private system.windows.Forms.MenuItem Menuitem1;
Private system.windows.Forms.MenuItem MenuItem_start;
Private system.windows.Forms.MenuItem MenuItem_exit;
Private system.windows.Forms.MenuItem MenuItem4;
Private system.windows.Forms.MenuItem MenuItem_about;
Private system.windows.Forms.Label label1;
Private system.windows.Forms.Panel Panel2;
Private system.windows.Forms.Label label2;
Private system.windows.Forms.Panel PanelNext;
Private system.windows.Forms.Label label3;
Private system.windows.Forms.Label lab_score;
Private system.windows.Forms.Label label4;
Private system.windows.Forms.Label lab_current_speed;
Blockinterface O;
Graphics g;
Public mainform ()
{
//
// Windows Form Designer Support
//
InitializationComponent ();
//
// Todo: Add any constructor code after INITIALIZECOMPONENT call
//
}
///
/// Clean all the resources being used.
///
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing)
{
IF (Components! = NULL)
{
Components.dispose ();
}
}
Base.dispose (Disposing);
}
#Region Windows Form Designer Generated Code
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
///
Private vidinitiRizeComponent ()
{
This.Components = new system.componentmodel.container ();
System.Resources.ResourceManager resources = new system.resources.resourceManager (Typeof); this.panel1 = new system.windows.forms.Panel ();
THIS.LABEL1 = New System.windows.Forms.label ();
this.timer1 = new system.windows.forms.timer (this.components);
This.mainMenu1 = new system.windows.Forms.mainMenu ();
THIS.MENUITEM1 = New System.windows.Forms.Menuitem ();
THIS.MENUITEM_START = new system.windows.Forms.MenuItem ();
THIS.MENUITEM_EXIT = New System.windows.Forms.MenuItem ();
This.Menuitem4 = new system.windows.Forms.MenuItem ();
THIS.MENUITEM_ABOUT = New System.windows.Forms.MenuItem ();
This.Panel2 = new system.windows.Forms.Panel ();
THIS.LAB_CURRENT_SPEED = New System.windows.Forms.label ();
THIS.LABEL4 = New System.windows.Forms.label ();
THIS.LAB_SCORE = New System.windows.Forms.Label ();
This.label3 = new system.windows.Forms.label ();
This.PanelNext = new system.windows.Forms.Panel ();
THIS.LABEL2 = New System.windows.Forms.label ();
This.Panel1.suspendlayout ();
this.Panel2.suspendlayout ();
THIS.SUSPENDLAYOUT ();
//
// panel1
//
THIS.PANEL1.BACKCOLOR = system.drawing.systemcolors.activecaption;
this.Panel1.controls.add (this.label1);
This.Panel1.dock = system.windows.Forms.dockStyle.bottom
This.Panel1.Location = new system.drawing.point (0, 403);
this.Panel1.name = "panel1";
This.Panel1.size = new system.drawing.size (410, 40);
This.Panel1.tabindex = 1;
//
// label1
//
THIS.LABEL1.BACKCOLOR = system.drawing.color.silver;
This.label1.dock = system.windows.forms.dockstyle.Fill;
THIS.Label1.Location = new system.drawing.point (0, 0);
THIS.LABEL1.NAME = "label1";
THIS.Label1.size = new system.drawing.size (410, 40); this.label1.tabindex = 0;
THIS.Label1.Text = "Programmed by Jason Verson 1.0";
THIS.Label1.TextAlign = system.drawing.contentAlignment.middleCenter;
//
// Timer1
//
this.timer1.interval = 1000;
This.Timer1.Tick = new system.eventhandler (this.timer1_thing);
//
// mainmenu1
//
this.mainMenu1.Menuitems.Addrange (new system.windows.forms.MenuItem [] {
This.Menuitem1,
THIS.MENUITEM4});
//
// Menuitem1
//
THIS.MENUITEM1.INDEX = 0;
This.Menuitem1.Menuitems.Addrange (new system.windows.forms.MenuItem [] {
this.MenuItem_Start,
This.MenuItem_exit});
this.Menuitem1.text = "Operation";
//
// Menuitem_Start
//
this.MenuItem_Start.index = 0;
THIS.MENUITEM_START.SHORTCUT = System.windows.Forms.Shortcut.f2;
This.Menuitem_Start.Text = "Start";
THIS.MENUITEM_START.Click = New System.EventHandler (this.MenuItem_start_click);
//
// Menuitem_exit
//
this.MenuItem_exit.index = 1;
THIS.MENUITEM_EXIT.SHORTCUT = System.windows.Forms.Shortcut.Artf4;
this.Menuitem_exit.text = "Exit";
THIS.MENUITEM_EXIT.CLICK = New System.EventHandler (this.MenuItem_exit_click);
//
// Menuitem4
//
this.Menuitem4.index = 1;
this.Menuitem4.Menuitems.addrange (new system.windows.forms.MenuItem [] {
THIS.MENUITEM_ABOUT};
this.Menuitem4.text = "Help";
//
// MenuItem_about
//
THIS.MENUITEM_ABOUT.INDEX = 0;
THIS.MENUITEM_ABOUT.TEXT = "About";
THIS.MENUITEM_ABOUT.Click = New System.EventHandler (this.MenuItem_about_click);
//
// panel2
//
THIS.PANEL2.BACKCOLOR = system.drawing.color.silver;
this.Panel2.controls.add (this.Lab_current_speed);
This.Panel2.controls.add (this.label4);
This.Panel2.controls.add (this.Lab_score);
This.Panel2.controls.add (this.label3);
This.Panel2.controls.add (this.PanelNext);
This.Panel2.controls.add (this.label2);
This.Panel2.dock = system.windows.Forms.dockStyle.right;
This.Panel2.location = new system.drawing.point (306, 0);
this.Panel2.name = "panel2";
This.Panel2.size = new system.drawing.size (104, 403);
this.Panel2.tabindex = 2;
//
// lab_current_speed
//
THIS.LAB_CURRENT_SPEED.DOCK = system.windows.Forms.dockStyle.top;
THIS.LAB_CURRENT_SPEED.LOCATION = New System.drawing.Point (0, 200);
THIS.LAB_CURRENT_SPEED.NAME = "lab_current_speed";
THIS.LAB_CURRENT_SPEED.SIZE = New System.drawing.size (104, 16);
THIS.LAB_CURRENT_SPEED.TABINDEX = 5;
THIS.LAB_CURRENT_SPEED.TEXT = "0";
//
// label4
//
This.label4.dock = system.windows.forms.dockstyle.top;
THIS.LABEL4.LOCATION = New System.drawing.Point (0, 176);
THIS.LABEL4.NAME = "label4";
THIS.Label4.size = new system.drawing.size (104, 24);
THIS.LABEL4.TABINDEX = 4;
THIS.LABEL4.TEXT = "CURRENT Speed:";
//
// lab_score
//
THIS.LAB_SCORE.DOCK = system.windows.forms.dockstyle.top;
This.Lab_score.location = new system.drawing.point (0, 160);
THIS.LAB_SCORE.NAME = "lab_score";
THIS.LAB_SCORE.SIZE = New System.drawing.size (104, 16);
THIS.LAB_SCORE.TABINDEX = 3;
this.Lab_score.text = "0";
//
// label3
//
THIS.LABEL3.DOCK = system.windows.forms.dockstyle.top;
This.Label3.Location = new system.drawing.point (0, 136);
THIS.LABEL3.NAME = "label3";
THIS.Label3.size = new system.drawing.size (104, 24); this.label3.tabindex = 2;
THIS.Label3.Text = "score:";
//
// PanelNext
//
This.PanelNext.dock = system.windows.Forms.dockStyle.top;
This.PanelNext.Location = new system.drawing.point (0, 24);
This.PanelNext.name = "panelnext";
This.PanelNext.Size = new system.drawing.size (104, 112);
this.PanelNext.tabindex = 1;
//
// label2
//
This.Label2.dock = system.windows.Forms.dockStyle.top;
THIS.LABEL2.LOCATION = New System.drawing.Point (0, 0);
THIS.LABEL2.NAME = "label2";
THIS.Label2.size = new system.drawing.size (104, 24);
THIS.Label2.tabindex = 0;
THIS.LABEL2.TEXT = "Next:";
//
// mainform
//
THIS.AUTOSCALEBASESIZE = New System.drawing.size (6, 14);
THISTEM.DRAWING.SYSTEMCOLORS.WINDOW;
THIS.CLIENTSIZE = New System.drawing.size (410, 443);
This.Controls.add (this.Panel2);
This.Controls.add (this.Panel1);
This.FormBorderstyle = system.windows.Forms.FormBorderstyle.FixedDialog;
This.icon = ((System.drawing.icon) ("$ this.icon")))
THIS.MAXIMIZEBOX = FALSE;
THIS.MENU = this.mainMenu1;
THIS.MINIMIZEBOX = FALSE;
THIS.NAME = "mainform";
This.startPosition = system.windows.forms.formstartPosition.CenterScreen
THIS.TEXT = "Russian Square Test Version";
This.keyDown = new system.windows.Forms.KeyEventHandler (this.mainform_keydown);
This.keyup = new system.windows.Forms.keyeventhandler (this.mainform_keyup);
This.Paint = new system.windows.Forms.PainteventHandler (this.mainform_paint);
this.Panel1.ResumeLayout (false);
This.Panel2.ResumeLayout (false);
THIS.ResumeLayout (false);
#ndregion
///
/// The main entry point for the application.
///
[Stathread]
Static void main ()
{
Application.run (new mainform ());
}
Private void Timer1_Tick (Object Sender, System.EventArgs E)
{
IF (O.canmove (Common.Down))
{
O.Move (Common.Down);
}
Else
{
O.Fillmatrix ();
Block.collector ();
THIS.LAB_SCORE.TEXT = Common.score.toString ();
this.timer1.interval = block.getspeed ();
THIS.LAB_CURRENT_SPEED.TEXT = Common.Speed.tostring ();
o = block.createblock ();
Block.drawnextblock (this.PanelNext.createGraphics ());
IF (O.ISOVER ())
{
this.timer1.enabled = false;
Block.gameOver ();
This.PanelNext.createGraphics (). Clear (color.silver);
THIS.LAB_CURRENT_SPEED.TEXT = "0";
this.Lab_score.text = "0";
this.timer1.interval = 1000;
}
}
}
Private void mainform_keydown (Object Sender, System.Windows.Forms.Keyeventargs E)
{
IF (e.keycode == keys.Left)
{
O.MOVE (Common.Left);
}
IF (e.keycode == keys.right)
{
O.Move (Common.right);
}
IF (e.keycode == keys.down)
{
this.timer1.interval = 30;
}
IF (e.keycode == keys.up)
{
O.circle ();
}
}
Private void mainform_keyup (Object Sender, System.Windows.Windows E)
{
this.timer1.interval = block.getspeed ();
}
Private void mainform_paint (Object Sender, System.Windows.Forms.PainteventArgs E)
{
IF (common.blackpen == null)
{
Return;
}
BLOCK.REFRESH ();
Block.drawnextblock (this.PanelNext.createGraphics ());
}
Private void menuitem_start_click (Object Sender, System.Eventargs E)
{
g = this.creategraphics ();
Common.setCommon (g);
THIS.BACKCOLOR = Color.White;
THIS.REFRESH ();
o = block.createblock ();
Block.drawnextBlock (this.PanelNext.creategraphics ()); o.drawself ();
THIS.SELECT ();
THIS.TIMER1.ENABED = TRUE;
}
Private void menuitem_exit_click (Object Sender, System.EventArgs E)
{
THIS.CLOSE ();
}
Private void menuitem_about_click (Object Sender, System.EventArgs E)
{
Messagebox.show (this, "Jasonjin", "Welcome");
}
}
}