ハローワールド:私の最初のゲームロシアブロック(C#)
一日で书いたプログラムを使って、初めてこれに触れて、hello worldプログラムになって、実现の方法などを书いて、各位の大侠が軽蔑しないでください、ちょうどこれに接触します.
設計思想:
クラシックなロシアのブロックには7つの基本的な形状があり、各形状には4つのブロックがあり、図形の変形はそのうちの1つのブロックを固定することができ、他の3つのブロックはこのブロックの位置によって決定され、例えば
1
2 --> 3 2 1
3 4 4
ゲーム領域はブロックサイズの整数倍に設定されており、左から右へ移動してもブロックの幅の距離で移動することで、位置ずれを保証できます.
ゲームの消行用ビット配列は、例えばゲーム領域幅を12個と定義すると、16進数0 xFFFが設けられ、ゲーム行配列を判断することでその行が満たされているか否かを判定することができる.行がいっぱいになったら、その行を消して、行の上の行を1行下げます.1つの図形が底部に落下することも,行配列に基づいて落下を継続できるか否かを判定する.1つのtimerでゲームの進行速度を制御し,一度に異なる複数の行の得点が異なることを消去し,総得点に基づいてゲームレベルを判定し,レベルに応じてゲーム速度を設定する.
Squareクラス、ブロックの基本的なプロパティといくつかの方法を保存するために使用されます
Blockクラス、図形のいくつかの属性と方法
GameFieldクラスはゲームのいくつかの属性と方法を保存するために使用します
timerのtickイベント
添付ファイルはエンジニアリングファイルで、vs 2005でコンパイルしました.
設計思想:
クラシックなロシアのブロックには7つの基本的な形状があり、各形状には4つのブロックがあり、図形の変形はそのうちの1つのブロックを固定することができ、他の3つのブロックはこのブロックの位置によって決定され、例えば
1
2 --> 3 2 1
3 4 4
ゲーム領域はブロックサイズの整数倍に設定されており、左から右へ移動してもブロックの幅の距離で移動することで、位置ずれを保証できます.
ゲームの消行用ビット配列は、例えばゲーム領域幅を12個と定義すると、16進数0 xFFFが設けられ、ゲーム行配列を判断することでその行が満たされているか否かを判定することができる.行がいっぱいになったら、その行を消して、行の上の行を1行下げます.1つの図形が底部に落下することも,行配列に基づいて落下を継続できるか否かを判定する.1つのtimerでゲームの進行速度を制御し,一度に異なる複数の行の得点が異なることを消去し,総得点に基づいてゲームレベルを判定し,レベルに応じてゲーム速度を設定する.
Squareクラス、ブロックの基本的なプロパティといくつかの方法を保存するために使用されます
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace MyTetris
{
class Square //Square 。
{
#region
public Point Location; //
public Size Size; //
public Color ForeColor; //
public Color BackColor; //
#endregion
/// <summary>
/// Square
/// </summary>
/// <param name="InitialSize"></param>
/// <param name="InitialBackcolor"></param>
/// <param name="InitialForecolor"></param>
public Square(Size InitialSize, Color InitialBackcolor, Color InitialForecolor)
{
//
Size = InitialSize;
BackColor = InitialBackcolor;
ForeColor = InitialForecolor;
}
/// <summary>
///
/// </summary>
/// <param name="WinHandle"></param>
public void Show(System.IntPtr WinHandle)
{
Graphics GameGraphics;
GraphicsPath graphPath;
PathGradientBrush brushSquare;
Color[] surroundColor;
Rectangle rectSquare;
GameGraphics = Graphics.FromHwnd(WinHandle); //
//
graphPath = new GraphicsPath();
rectSquare = new Rectangle(Location.X, Location.Y, Size.Width, Size.Height);
graphPath.AddRectangle(rectSquare);
//
brushSquare = new PathGradientBrush(graphPath);
brushSquare.CenterColor = ForeColor;
surroundColor = new Color[] { BackColor };
brushSquare.SurroundColors = surroundColor;
//
GameGraphics.FillPath(brushSquare, graphPath);
}
/// <summary>
///
/// </summary>
/// <param name="WinHandle"></param>
public void Hide(System.IntPtr WinHandle)
{
Graphics GameGraphics;
Rectangle rectSquare;
GameGraphics = Graphics.FromHwnd(WinHandle);
//
rectSquare = new Rectangle(Location.X, Location.Y, Size.Width, Size.Height);
GameGraphics.FillRectangle(new SolidBrush(GameField.BackColor), rectSquare);
}
}
}
Blockクラス、図形のいくつかの属性と方法
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace MyTetris
{
class Block
{
#region
//
public enum BlockTypes
{
Undefined = 0,
O = 1,
I = 2,
J = 3,
L = 4,
T = 5,
Z = 6,
S = 7
};
//
public enum RotationDirections
{
NORTH = 1,
EAST = 2,
SOUTH = 3,
WEST = 4
};
//
public Square square1;
public Square square2;
public Square square3;
public Square square4;
private const int squareSize = GameField.SquareSize;
public BlockTypes BlockType;
//private Color[] backColors ={ Color.Empty, Color.Red, Color.Blue, Color.Red, Color.Yellow, Color.Green, Color.White, Color.Black };
//private Color[] foreColors ={ Color.Empty, Color.Purple, Color.LightBlue, Color.Yellow, Color.Red, Color.LightGreen, Color.Black, Color.White };
private Color[] backColors ={ Color.Empty, Color.White, Color.White, Color.White, Color.White, Color.White, Color.White, Color.White };
private Color[] foreColors ={ Color.Empty, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black };
//
public RotationDirections StatusRotation = RotationDirections.NORTH;
#endregion
/// <summary>
/// Block
/// </summary>
/// <param name="location"></param>
/// <param name="newBlockTypes"></param>
public Block(Point location, BlockTypes newBlockTypes)
{
if (newBlockTypes == BlockTypes.Undefined)
{
BlockType = (BlockTypes)(new Random().Next(7)) + 1;
}
else
{
BlockType = newBlockTypes;
}
//
square1 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]);
square2 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]);
square3 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]);
square4 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]);
#region
switch (BlockType)
{
// 1 2
// 3 4
case BlockTypes.O:
square1.Location = new Point(location.X, location.Y);
square2.Location = new Point(location.X + squareSize, location.Y);
square3.Location = new Point(location.X, location.Y + squareSize);
square4.Location = new Point(location.X + squareSize, location.Y + squareSize);
break;
// 1
// 2
// 3
// 4
case BlockTypes.I:
square1.Location = new Point(location.X, location.Y);
square2.Location = new Point(location.X, location.Y + squareSize);
square3.Location = new Point(location.X, location.Y + 2*squareSize);
square4.Location = new Point(location.X, location.Y + 3 * squareSize);
break;
// 1
// 2
//4 3
case BlockTypes.J:
square1.Location = new Point(location.X + squareSize, location.Y);
square2.Location = new Point(location.X + squareSize, location.Y + squareSize);
square3.Location = new Point(location.X + squareSize, location.Y + 2 * squareSize);
square4.Location = new Point(location.X, location.Y + 2 * squareSize);
break;
// 1
// 2
// 3 4
case BlockTypes.L:
square1.Location = new Point(location.X, location.Y);
square2.Location = new Point(location.X , location.Y + squareSize);
square3.Location = new Point(location.X, location.Y + 2 * squareSize);
square4.Location = new Point(location.X + squareSize, location.Y + 2 * squareSize);
break;
// 1 2 3
// 4
case BlockTypes.T:
square1.Location = new Point(location.X, location.Y);
square2.Location = new Point(location.X + squareSize, location.Y);
square3.Location = new Point(location.X + 2 * squareSize, location.Y);
square4.Location = new Point(location.X + squareSize, location.Y + squareSize);
break;
// 1 2
// 3 4
case BlockTypes.Z:
square1.Location = new Point(location.X, location.Y);
square2.Location = new Point(location.X + squareSize, location.Y);
square3.Location = new Point(location.X + squareSize, location.Y + squareSize);
square4.Location = new Point(location.X + 2 * squareSize, location.Y + squareSize);
break;
// 1 2
// 3 4
case BlockTypes.S:
square1.Location = new Point(location.X + squareSize, location.Y);
square2.Location = new Point(location.X + 2 * squareSize, location.Y);
square3.Location = new Point(location.X, location.Y + squareSize);
square4.Location = new Point(location.X + squareSize, location.Y + squareSize);
break;
}
#endregion
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public bool Down()
{
//
if (GameField.IsEmpty(square1.Location.X / squareSize, square1.Location.Y / squareSize + 1) &&
GameField.IsEmpty(square2.Location.X / squareSize, square2.Location.Y / squareSize + 1) &&
GameField.IsEmpty(square3.Location.X / squareSize, square3.Location.Y / squareSize + 1) &&
GameField.IsEmpty(square4.Location.X / squareSize, square4.Location.Y / squareSize + 1))
{
Hide(GameField.WinHandle);
//
square1.Location = new Point(square1.Location.X, square1.Location.Y + squareSize);
square2.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square3.Location = new Point(square3.Location.X, square3.Location.Y + squareSize);
square4.Location = new Point(square4.Location.X, square4.Location.Y + squareSize);
Show(GameField.WinHandle);
return true;
}
else
{
//
GameField.StopSquare(square1, square1.Location.X / squareSize, square1.Location.Y / squareSize);
GameField.StopSquare(square2, square2.Location.X / squareSize, square2.Location.Y / squareSize);
GameField.StopSquare(square3, square3.Location.X / squareSize, square3.Location.Y / squareSize);
GameField.StopSquare(square4, square4.Location.X / squareSize, square4.Location.Y / squareSize);
return false;
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public bool Right()
{
//
if (GameField.IsEmpty(square1.Location.X / squareSize + 1, square1.Location.Y / squareSize) &&
GameField.IsEmpty(square2.Location.X / squareSize + 1, square2.Location.Y / squareSize) &&
GameField.IsEmpty(square3.Location.X / squareSize + 1, square3.Location.Y / squareSize) &&
GameField.IsEmpty(square4.Location.X / squareSize + 1, square4.Location.Y / squareSize))
{
Hide(GameField.WinHandle);
//
square1.Location = new Point(square1.Location.X + squareSize, square1.Location.Y);
square2.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square3.Location = new Point(square3.Location.X + squareSize, square3.Location.Y);
square4.Location = new Point(square4.Location.X + squareSize, square4.Location.Y);
Show(GameField.WinHandle);
return true;
}
else
{
return false;
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public bool Left()
{
//
if (GameField.IsEmpty(square1.Location.X / squareSize - 1, square1.Location.Y / squareSize) &&
GameField.IsEmpty(square2.Location.X / squareSize - 1, square2.Location.Y / squareSize) &&
GameField.IsEmpty(square3.Location.X / squareSize - 1, square3.Location.Y / squareSize) &&
GameField.IsEmpty(square4.Location.X / squareSize - 1, square4.Location.Y / squareSize))
{
Hide(GameField.WinHandle);
//
square1.Location = new Point(square1.Location.X - squareSize, square1.Location.Y);
square2.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square3.Location.X - squareSize, square3.Location.Y);
square4.Location = new Point(square4.Location.X - squareSize, square4.Location.Y);
Show(GameField.WinHandle);
return true;
}
else
{
return false;
}
}
/// <summary>
///
/// </summary>
public void Rotate()
{
//
Point OldPosition1 = square1.Location;
Point OldPosition2 = square2.Location;
Point OldPosition3 = square3.Location;
Point OldPosition4 = square4.Location;
//
RotationDirections OldStatusRotation = StatusRotation;
Hide(GameField.WinHandle);
#region
switch (BlockType)
{
//
case BlockTypes.O:
break;
//
case BlockTypes.I:
#region
switch (StatusRotation)
{
// 1
// 2
// 3 --> 1 2 3 4
// 4
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square1.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X + 2 * squareSize, square2.Location.Y);
break;
// 1
// 2
// 1 2 3 4--> 3
// 4
case RotationDirections.EAST:
StatusRotation = RotationDirections.NORTH;
square1.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square4.Location = new Point(square2.Location.X, square2.Location.Y + 2 * squareSize);
break;
}
break;
#endregion
//
case BlockTypes.J:
#region
switch (StatusRotation)
{
// 1 4
// 2 -->3 2 1
//4 3
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square1.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y - squareSize);
break;
// 4 3 4
// 3 2 1 --> 2
// 1
case RotationDirections.EAST:
StatusRotation = RotationDirections.SOUTH;
square1.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y - squareSize);
break;
// 3 4
// 2 -->1 2 3
// 1 4
case RotationDirections.SOUTH:
StatusRotation = RotationDirections.WEST;
square1.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y + squareSize);
break;
// 1
// 1 2 3 --> 2
// 4 4 3
case RotationDirections.WEST:
StatusRotation = RotationDirections.NORTH;
square1.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y + squareSize);
break;
}
break;
#endregion
//
case BlockTypes.L:
#region
switch (StatusRotation)
{
// 1
// 2 --> 3 2 1
// 3 4 4
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square1.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y + squareSize);
break;
// 4 3
// 3 2 1 --> 2
// 4 1
case RotationDirections.EAST:
StatusRotation = RotationDirections.SOUTH;
square1.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y - squareSize);
break;
// 4 3 4
// 2 --> 1 2 3
// 1
case RotationDirections.SOUTH:
StatusRotation = RotationDirections.WEST;
square1.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y - squareSize);
break;
// 4 1
// 1 2 3 --> 2
// 3 4
case RotationDirections.WEST:
StatusRotation = RotationDirections.NORTH;
square1.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y + squareSize);
break;
}
break;
#endregion
//
case BlockTypes.T:
#region
switch (StatusRotation)
{
// 1
// 1 2 3 --> 4 2
// 4 3
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square1.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
break;
// 1 4
// 4 2 --> 3 2 1
// 3
case RotationDirections.EAST:
StatusRotation = RotationDirections.SOUTH;
square1.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
break;
// 4 3
// 3 2 1 --> 2 4
// 1
case RotationDirections.SOUTH:
StatusRotation = RotationDirections.WEST;
square1.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square3.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
break;
// 3
// 2 4 --> 1 2 3
// 1 4
case RotationDirections.WEST:
StatusRotation = RotationDirections.NORTH;
square1.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X + squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
break;
}
break;
#endregion
//
case BlockTypes.Z:
#region
switch (StatusRotation)
{
// 1
// 1 2 --> 3 2
// 3 4 4
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square1.Location = new Point(square2.Location.X, square2.Location.Y - squareSize);
square3.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square4.Location = new Point(square2.Location.X - squareSize, square2.Location.Y + squareSize);
break;
// 1
// 3 2 --> 1 2
// 4 3 4
case RotationDirections.EAST:
StatusRotation = RotationDirections.NORTH;
square1.Location = new Point(square2.Location.X - squareSize, square2.Location.Y);
square3.Location = new Point(square2.Location.X, square2.Location.Y + squareSize);
square4.Location = new Point(square2.Location.X + squareSize, square2.Location.Y + squareSize);
break;
}
break;
#endregion
//
case BlockTypes.S:
#region
switch (StatusRotation)
{
// 1 2 3
// 3 4 --> 4 1
// 2
case RotationDirections.NORTH:
StatusRotation = RotationDirections.EAST;
square2.Location = new Point(square1.Location.X, square1.Location.Y + squareSize);
square3.Location = new Point(square1.Location.X - squareSize, square1.Location.Y - squareSize);
square4.Location = new Point(square1.Location.X - squareSize, square1.Location.Y);
break;
// 3 1 2
// 4 1 --> 3 4
// 2
case RotationDirections.EAST:
StatusRotation = RotationDirections.NORTH;
square2.Location = new Point(square1.Location.X + squareSize, square1.Location.Y);
square3.Location = new Point(square1.Location.X - squareSize, square1.Location.Y + squareSize);
square4.Location = new Point(square1.Location.X, square1.Location.Y + squareSize);
break;
}
break;
#endregion
}
#endregion
//
if (!(GameField.IsEmpty(square1.Location.X / squareSize, square1.Location.Y / squareSize) &&
GameField.IsEmpty(square2.Location.X / squareSize, square2.Location.Y / squareSize) &&
GameField.IsEmpty(square3.Location.X / squareSize, square3.Location.Y / squareSize) &&
GameField.IsEmpty(square4.Location.X / squareSize, square4.Location.Y / squareSize)))
{
StatusRotation = OldStatusRotation;
square1.Location = OldPosition1;
square2.Location = OldPosition2;
square3.Location = OldPosition3;
square4.Location = OldPosition4;
}
Show(GameField.WinHandle);
}
/// <summary>
///
/// </summary>
/// <param name="WinHandle"></param>
public void Show(System.IntPtr WinHandle)
{
square1.Show(WinHandle);
square2.Show(WinHandle);
square3.Show(WinHandle);
square4.Show(WinHandle);
}
/// <summary>
/// s
/// </summary>
/// <param name="WinHandle"></param>
public void Hide(System.IntPtr WinHandle)
{
square1.Hide(WinHandle);
square2.Hide(WinHandle);
square3.Hide(WinHandle);
square4.Hide(WinHandle);
}
/// <summary>
/// 1、2、3、4
/// </summary>
/// <returns></returns>
public int Top()
{
return Math.Min(square1.Location.Y,Math.Min(square2.Location.Y,Math.Min(square3.Location.Y,square4.Location.Y)));
}
}
}
GameFieldクラスはゲームのいくつかの属性と方法を保存するために使用します
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace MyTetris
{
class GameField
{
#region
public static System.IntPtr WinHandle;
public static Color BackColor;
public const int SquareSize = 20;
public const int Width = 12; // ,16 square
public const int Height = 20;// ,29 square
private static Square[,] arrGameField = new Square[Width, Height]; // ,
public static int[] arrBitGameField = new int[Height]; // ,
private const int bitEmpty = 0x0; //0000 0000 0000
private const int bitFull = 0xFFF; //1111 1111 1111
#endregion
/// <summary>
/// x,y
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static bool IsEmpty(int x, int y)
{
//
if ((y < 0 || y >= Height) || (x < 0 || x >= Width))
{
return false;
}
//
else if ((arrBitGameField[y] & (1 << x)) != 0)
{
return false;
}
return true;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static int CheckLines()
{
int CheckLines_result = 0;
int y = Height - 1;
while (y >= 0)
{
// ,
if (arrBitGameField[y] == bitEmpty)
{
y = 0;
}
//
if (arrBitGameField[y] == bitFull)
{
CheckLines_result++;
//
for (int index = y; index >= 0; index--)
{
// 1
if (index > 0)
{
arrBitGameField[index] = arrBitGameField[index - 1];
for (int x = 0; x < Width; x++)
{
arrGameField[x, index] = arrGameField[x, index - 1];
if (arrGameField[x, index] != null)
{
arrGameField[x, index].Location = new Point(arrGameField[x, index].Location.X, arrGameField[x, index].Location.Y + SquareSize);
}
}
}
//
else
{
arrBitGameField[index] = bitEmpty;
for (int x = 0; x < Width; x++)
{
arrGameField[x, index] = null;
}
}
}
}
else
{
y--;
}
}
return CheckLines_result;
}
/// <summary>
///
/// </summary>
/// <param name="square"></param>
/// <param name="x"></param>
/// <param name="y"></param>
public static void StopSquare(Square square, int x, int y)
{
arrBitGameField[y] = arrBitGameField[y] | (1 << x);
arrGameField[x, y] = square;
}
/// <summary>
///
/// </summary>
public static void Redraw()
{
for (int y = Height - 1; y >= 0; y--)
{
if (arrBitGameField[y] != bitEmpty)
{
for (int x = Width - 1; x >= 0; x--)
{
if (arrGameField[x, y] != null)
{
arrGameField[x, y].Show(WinHandle);
}
}
}
}
}
}
}
timerのtickイベント
private void tmrGameClock_Tick(object sender, EventArgs e)
{
//
int erasedLines = 0;
if (stillProcessind)
{
return;
}
stillProcessind = true;
if (!CurrentBlock.Down())
{
if(CurrentBlock.Top()==0)
{
tmrGameClock.Enabled = true;
cmdStart.Enabled = true;
//MessageBox.Show("Game Over", ".NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Stop);
labFailed.Visible = true;
stillProcessind = false;
tmrGameClock.Enabled = false;
return;
}
erasedLines = GameField.CheckLines();
if (erasedLines > 0)
{
//
switch (erasedLines)
{
case 1: score += 10 * erasedLines; break;
case 2: score += 15 * erasedLines; break;
case 3: score += 20 * erasedLines; break;
case 4: score += 25 * erasedLines; break;
}
labScore.Text = score.ToString();
//
if (score < 200)
level = 1;
else if (score < 400)
level = 2;
else if (score < 800)
level = 3;
else if (score < 1000)
level = 4;
else if (score < 1200)
level = 5;
else
level = 6;
labLevel.Text = level.ToString();
//
tmrGameClock.Interval = 400 - (level - 1) * 50;
picBackground.Invalidate();
Application.DoEvents();
GameField.Redraw();
}
CurrentBlock = new Block(new Point(GameField.SquareSize * 6, 0), NextBlock.BlockType);
CurrentBlock.Show(picBackground.Handle);
NextBlock.Hide(picNextBlock.Handle);
NextBlock = new Block(new Point(20, 10), Block.BlockTypes.Undefined);
NextBlock.Show(picNextBlock.Handle);
}
stillProcessind = false;
}
添付ファイルはエンジニアリングファイルで、vs 2005でコンパイルしました.