目录
实践过程
效果
代码
public partial class Form : Form
{
public Form()
{
InitializeComponent();
}
Russia MyRussia = new Russia();
Russia TemRussia = new Russia();
public static int CakeNO =;
public static bool become = false;
public static bool isbegin = false;
public bool ispause = true;
public Timer timer = new Timer();
private void button_Click(object sender, EventArgs e)
{
MyRussia.ConvertorClear();
MyRussia.firstPoi = new Point(, 20);
label.Text = "0";
label.Text = "0";
MyRussia.Label_Linage = label;
MyRussia.Label_Fraction = label;
timer.Interval = 500;
timer.Enabled = false;
timer.Enabled = true;
Random rand = new Random();
CakeNO = rand.Next(, 8);
MyRussia.CakeMode(CakeNO);
MyRussia.Protract(panel);
beforehand();
MyRussia.PlaceInitialization();
isbegin = true;
ispause = true;
MyRussia.timer = timer;
button.Text = "暂停";
ispause = true;
textBox.Focus();
}
public void beforehand()
{
Graphics P = panel3.CreateGraphics();
P.FillRectangle(new SolidBrush(Color.Black), 0, 0, panel3.Width, panel3.Height);
Random rand = new Random();
CakeNO = rand.Next(, 8);
TemRussia.firstPoi = new Point(, 30);
TemRussia.CakeMode(CakeNO);
TemRussia.Protract(panel);
}
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if (!isbegin)
return;
if (!ispause)
return;
if (e.KeyCode == Keys.Up)
MyRussia.MyConvertorMode();
if (e.KeyCode == Keys.Down)
{
timer.Interval = 300;
MyRussia.ConvertorMove();
}
if (e.KeyCode == Keys.Left)
MyRussia.ConvertorMove();
if (e.KeyCode == Keys.Right)
MyRussia.ConvertorMove();
}
private void timer_Tick(object sender, EventArgs e)
{
MyRussia.ConvertorMove();
if (become)
{
beforehand();
become = false;
}
textBox.Focus();
}
private void Form_KeyUp(object sender, KeyEventArgs e)
{
if (!isbegin)
return;
if (!ispause)
return;
if (e.KeyCode == Keys.Down)
{
timer.Interval = 500;
}
textBox.Focus();
}
private void button_Click(object sender, EventArgs e)
{
if (timer.Enabled == true)
{
timer.Stop();
button.Text = "继续";
ispause = false;
textBox.Focus();
}
else
{
timer.Start();
button.Text = "暂停";
ispause = true;
textBox.Focus();
}
}
private void panel_Paint(object sender, PaintEventArgs e)
{
if (isbegin)
{
for (int i =; i <= (panel1.Width / 20 - 1); i++)
{
for (int j =; j <= (panel1.Height / 20 - 1); j++)
{
Rectangle rect = new Rectangle(i * + 1, j * 20 + 1, 19, 19);
e.Graphics.FillRectangle(new SolidBrush(Russia.PlaceColor[i, j]), rect);
}
}
}
}
private void panel_Paint(object sender, PaintEventArgs e)
{
if (isbegin)
{
TemRussia.firstPoi = new Point(, 30);
TemRussia.CakeMode(CakeNO);
TemRussia.Protract(panel);
}
}
}
partial class Form
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.panel = new System.Windows.Forms.Panel();
this.button = new System.Windows.Forms.Button();
this.textBox = new System.Windows.Forms.TextBox();
this.timer = new System.Windows.Forms.Timer(this.components);
this.button = new System.Windows.Forms.Button();
this.panel = new System.Windows.Forms.Panel();
this.panel = new System.Windows.Forms.Panel();
this.label = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.panel.SuspendLayout();
this.SuspendLayout();
this.panel.BackColor = System.Drawing.SystemColors.WindowText;
this.panel.Location = new System.Drawing.Point(4, 5);
this.panel.Name = "panel1";
this.panel.Size = new System.Drawing.Size(281, 401);
this.panel.TabIndex = 0;
this.panel.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
this.button.Location = new System.Drawing.Point(291, 341);
this.button.Name = "button1";
this.button.Size = new System.Drawing.Size(75, 23);
this.button.TabIndex = 1;
this.button.Text = "开始";
this.button.UseVisualStyleBackColor = true;
this.button.Click += new System.EventHandler(this.button1_Click);
this.textBox.Location = new System.Drawing.Point(291, 480);
this.textBox.Name = "textBox1";
this.textBox.Size = new System.Drawing.Size(10, 21);
this.textBox.TabIndex = 2;
this.textBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.textBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);
this.timer.Interval = 300;
this.timer.Tick += new System.EventHandler(this.timer1_Tick);
this.button.Location = new System.Drawing.Point(291, 370);
this.button.Name = "button2";
this.button.Size = new System.Drawing.Size(75, 23);
this.button.TabIndex = 3;
this.button.Text = "暂停";
this.button.UseVisualStyleBackColor = true;
this.button.Click += new System.EventHandler(this.button2_Click);
this.panel.BackColor = System.Drawing.Color.Black;
this.panel.Controls.Add(this.label4);
this.panel.Controls.Add(this.label3);
this.panel.Controls.Add(this.label2);
this.panel.Controls.Add(this.label1);
this.panel.Controls.Add(this.panel3);
this.panel.Location = new System.Drawing.Point(291, 5);
this.panel.Name = "panel2";
this.panel.Size = new System.Drawing.Size(120, 308);
this.panel.TabIndex = 4;
this.panel.Location = new System.Drawing.Point(10, 10);
this.panel.Name = "panel3";
this.panel.Size = new System.Drawing.Size(100, 100);
this.panel.TabIndex = 0;
this.panel.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
this.label.AutoSize = true;
this.label.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label.ForeColor = System.Drawing.SystemColors.Window;
this.label.Location = new System.Drawing.Point(4, 148);
this.label.Name = "label1";
this.label.Size = new System.Drawing.Size(59, 16);
this.label.TabIndex = 1;
this.label.Text = "行数:";
this.label.AutoSize = true;
this.label.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label.ForeColor = System.Drawing.Color.White;
this.label.Location = new System.Drawing.Point(4, 193);
this.label.Name = "label2";
this.label.Size = new System.Drawing.Size(59, 16);
this.label.TabIndex = 2;
this.label.Text = "分数:";
this.label.AutoSize = true;
this.label.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label.ForeColor = System.Drawing.Color.White;
this.label.Location = new System.Drawing.Point(48, 150);
this.label.Name = "label3";
this.label.Size = new System.Drawing.Size(15, 14);
this.label.TabIndex = 3;
this.label.Text = "0";
this.label.AutoSize = true;
this.label.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label.ForeColor = System.Drawing.Color.White;
this.label.Location = new System.Drawing.Point(48, 195);
this.label.Name = "label4";
this.label.Size = new System.Drawing.Size(15, 14);
this.label.TabIndex = 4;
this.label.Text = "0";
this.AutoScaleDimensions = new System.Drawing.SizeF(F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(, 411);
this.Controls.Add(this.panel);
this.Controls.Add(this.button);
this.Controls.Add(this.textBox);
this.Controls.Add(this.button);
this.Controls.Add(this.panel);
this.MaximizeBox = false;
this.Name = "Form";
this.Text = "俄罗斯方块";
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form_KeyUp);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form_KeyDown);
this.panel.ResumeLayout(false);
this.panel.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Button button;
private System.Windows.Forms.TextBox textBox;
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.Button button;
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Label label;
private System.Windows.Forms.Label label;
private System.Windows.Forms.Label label;
private System.Windows.Forms.Label label;
}
class Russia
{
public Point firstPoi = new Point(, 20);
public static Color[,] PlaceColor;
public static bool[,] Place;
public static int conWidth =;
public static int conHeight =;
public static int maxY =;
public static int conMax =;
public static int conMin =;
bool[] tem_Array = { false, false, false, false };
Color ConColor = Color.Coral;
Point[] ArryPoi = new Point[];
Point[] Arryfront = new Point[];
int Cake =;
int Convertor =;
Control Mycontrol = new Control();
public Label Label_Linage = new Label();
public Label Label_Fraction = new Label();
public static int[] ArrayCent = new int[] {, 5, 9, 15 };
public Timer timer = new Timer();
public void CakeMode(int n)
{
ArryPoi[] = firstPoi;
switch (n)
{
case:
{
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y + Cake);
ArryPoi[] = new Point(firstPoi.X + Cake, firstPoi.Y + Cake);
ConColor = Color.Fuchsia;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X + Cake, firstPoi.Y);
ConColor = Color.Yellow;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y + Cake);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y + Cake);
ConColor = Color.CornflowerBlue;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X + Cake, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y);
ConColor = Color.Blue;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X + Cake, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y - Cake);
ConColor = Color.Silver;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X + Cake, firstPoi.Y);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y);
ArryPoi[] = new Point(firstPoi.X - Cake*2, firstPoi.Y);
ConColor = Color.Red;
Convertor =;
break;
}
case:
{
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y);
ArryPoi[] = new Point(firstPoi.X - Cake, firstPoi.Y - Cake);
ArryPoi[] = new Point(firstPoi.X, firstPoi.Y - Cake);
ConColor = Color.LightGreen;
Convertor =;
break;
}
}
}
public void ConvertorClear()
{
if (Mycontrol != null)
{
Graphics g = Mycontrol.CreateGraphics();
Rectangle rect = new Rectangle(, 0, Mycontrol.Width, Mycontrol.Height);
MyPaint(g, new SolidBrush(Color.Black), rect);
}
}
public void ConvertorDelete()
{
Graphics g = Mycontrol.CreateGraphics();
for (int i =; i < ArryPoi.Length; i++)
{
Rectangle rect = new Rectangle(ArryPoi[i].X, ArryPoi[i].Y,, 20);
MyPaint(g, new SolidBrush(Color.Black), rect);
}
}
public void MyConvertorMode()
{
ConvertorDelete();
ConvertorMode(Convertor);
Protract(Mycontrol);
}
public void ConvertorMode(int n)
{
Point[] tem_ArrayPoi = new Point[];
Point tem_Poi = firstPoi;
int tem_n = n;
for (int i =; i < tem_ArrayPoi.Length; i++)
tem_ArrayPoi[i] = ArryPoi[i];
switch (n)
{
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y - Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y - Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X + Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake * 2, tem_Poi.Y);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y + Cake * 2);
tem_n =;
break;
}
case:
{
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y);
tem_ArrayPoi[] = new Point(tem_Poi.X - Cake, tem_Poi.Y - Cake);
tem_ArrayPoi[] = new Point(tem_Poi.X, tem_Poi.Y - Cake);
tem_n =;
break;
}
}
bool tem_bool = true;
for (int i =; i < tem_ArrayPoi.Length; i++)
{
if (tem_ArrayPoi[i].X / < 0)
{
tem_bool = false;
break;
}
if (tem_ArrayPoi[i].X / >= conWidth)
{
tem_bool = false;
break;
}
if (tem_ArrayPoi[i].Y / >= conHeight)
{
tem_bool = false;
break;
}
if (Place[tem_ArrayPoi[i].X /, tem_ArrayPoi[i].Y / 20])
{
tem_bool = false;
break;
}
}
if (tem_bool)
{
for (int i =; i < tem_ArrayPoi.Length; i++)
ArryPoi[i] = tem_ArrayPoi[i];
firstPoi = tem_Poi;
Convertor = tem_n;
}
}
public void Protract(Control control)
{
Mycontrol = control;
Graphics g = control.CreateGraphics();
for (int i =; i < ArryPoi.Length; i++)
{
Rectangle rect = new Rectangle(ArryPoi[i].X +, ArryPoi[i].Y + 1, 19, 19);
MyPaint(g, new SolidBrush(ConColor), rect);
}
}
public void MyPaint(Graphics g, SolidBrush SolidB, Rectangle rect)
{
g.FillRectangle(SolidB, rect);
}
public void ConvertorMove(int n)
{
for (int i =; i < Arryfront.Length; i++)
Arryfront[i] = ArryPoi[i];
switch (n)
{
case:
{
for (int i =; i < Arryfront.Length; i++)
Arryfront[i] = new Point(Arryfront[i].X, Arryfront[i].Y + Cake);
break;
}
case:
{
for (int i =; i < Arryfront.Length; i++)
Arryfront[i] = new Point(Arryfront[i].X - Cake, Arryfront[i].Y);
break;
}
case:
{
for (int i =; i < Arryfront.Length; i++)
Arryfront[i] = new Point(Arryfront[i].X + Cake, Arryfront[i].Y);
break;
}
}
bool tem_bool = MoveStop(n);
if (tem_bool)
{
ConvertorDelete();
for (int i =; i < Arryfront.Length; i++)
ArryPoi[i] = Arryfront[i];
firstPoi = ArryPoi[];
Protract(Mycontrol);
}
else
{
if (!tem_bool && n ==)
{
conMax =;
conMin = Mycontrol.Height;
for (int i =; i < ArryPoi.Length; i++)
{
if (ArryPoi[i].Y < maxY)
maxY = ArryPoi[i].Y;
Place[ArryPoi[i].X /, ArryPoi[i].Y / 20] = true;
PlaceColor[ArryPoi[i].X /, ArryPoi[i].Y / 20] = ConColor;
if (ArryPoi[i].Y > conMax)
conMax = ArryPoi[i].Y;
if (ArryPoi[i].Y < conMin)
conMin = ArryPoi[i].Y;
}
if (firstPoi.X == && firstPoi.Y == 20)
{
timer.Stop();
Form.isbegin = false;
return;
}
Random rand = new Random();
int CakeNO = rand.Next(, 8);
firstPoi = new Point(, 20);
CakeMode(Form.CakeNO);
Protract(Mycontrol);
RefurbishRow(conMax,conMin);
Form.become = true;
}
}
}
public void RefurbishRow(int Max,int Min)
{
Graphics g = Mycontrol.CreateGraphics();
int tem_max = Max /;
int tem_min = Min /;
bool tem_bool = false;
for (int i =; i < tem_Array.Length; i++)
tem_Array[i] = false;
int tem_n = maxY;
for (int i =; i < 4; i++)
{
if ((tem_min + i) >)
break;
tem_bool = false;
for (int k =; k < conWidth; k++)
{
if (!Place[k, tem_min + i])
{
tem_bool = true;
break;
}
}
if (!tem_bool)
{
tem_Array[i] = true;
}
}
int Progression =;
if (tem_Array[] == true || tem_Array[1] == true || tem_Array[2] == true || tem_Array[3] == true)
{
int Trow =;
for (int i = (tem_Array.Length -); i >= 0; i--)
{
if (tem_Array[i])
{
Trow = Min / + i;
for (int j = Trow; j >= ; j--)
{
for (int k =; k < conWidth; k++)
{
PlaceColor[k, j] = PlaceColor[k, j -];
Place[k, j] = Place[k, j -];
}
}
Min +=;
for (int k =; k < conWidth; k++)
{
PlaceColor[k,] = Color.Black;
Place[k,] = false;
}
Progression +=;
}
}
for (int i =; i < conWidth; i++)
{
for (int j =; j <= Max / 20; j++)
{
Rectangle rect = new Rectangle(i * Cake +, j * Cake + 1, 19, 19);
MyPaint(g, new SolidBrush(PlaceColor[i, j]), rect);
}
}
Label_Linage.Text = Convert.ToString(Convert.ToInt(Label_Linage.Text) + Progression);
Label_Fraction.Text = Convert.ToString(Convert.ToInt(Label_Fraction.Text) + ArrayCent[Progression - 1]);
}
}
public void PlaceInitialization()
{
conWidth=Mycontrol.Width /;
conHeight = Mycontrol.Height /;
Place = new bool[conWidth, conHeight];
PlaceColor = new Color[conWidth, conHeight];
for (int i =; i < conWidth; i++)
{
for (int j =; j < conHeight; j++)
{
Place[i, j] = false;
PlaceColor[i, j] = Color.Black;
}
}
maxY = conHeight * Cake;
}
public bool MoveStop(int n)
{
bool tem_bool = true;
int tem_width =;
int tem_height =;
switch (n)
{
case:
{
for (int i =; i < Arryfront.Length; i++)
{
tem_width = Arryfront[i].X /;
tem_height = Arryfront[i].Y /;
if (tem_height == conHeight || Place[tem_width, tem_height])
tem_bool = false;
}
break;
}
case:
{
for (int i =; i < Arryfront.Length; i++)
{
tem_width = Arryfront[i].X /;
tem_height = Arryfront[i].Y /;
if (tem_width == - || Place[tem_width, tem_height])
tem_bool = false;
}
break;
}
case:
{
for (int i =; i < Arryfront.Length; i++)
{
tem_width = Arryfront[i].X /;
tem_height = Arryfront[i].Y /;
if (tem_width == conWidth || Place[tem_width, tem_height])
tem_bool = false;
}
break;
}
}
return tem_bool;
}
}