Игровая система "Тетрис"

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

es(int l)

{

label2.Text = l.ToString();

}setLevel(int l)

{

label3.Text = l.ToString();

}MainWindow()

{

InitializeComponent();.listView1.Columns.Add(newColHeader("Name", 50, HorizontalAlignment.Left, true));.listView1.Columns.Add(newColHeader("Score", 46, HorizontalAlignment.Left, true));.listView1.Columns.Add(newColHeader("Level", 38, HorizontalAlignment.Left, true));.listView1.Columns.Add(newColHeader("Lines", 49, HorizontalAlignment.Left, true));.listView1.Columns.Add(newColHeader("Diff", 40, HorizontalAlignment.Left, true));i = 0;tr = newStreamReader("records.dat");(tr.Peek() != -1)

{

listView1.Items.Add(tr.ReadLine());

listView1.Items[i].SubItems.Add(tr.ReadLine());

listView1.Items[i].SubItems.Add(tr.ReadLine());

listView1.Items[i].SubItems.Add(tr.ReadLine());

listView1.Items[i].SubItems.Add(tr.ReadLine());

i++;

}.Close();

}OnPaint(PaintEventArgs e)

{

fullPaint = true;

gObj = Graphics.FromImage(PanelPad.Image);

gObj.SmoothingMode = SmoothingMode.HighSpeed;(debug.Enabled)

{

debug.Text = "";(int x = 0; x < 19; x++)

{(int y = 0; y < 10; y++)

{(table[y, x] == true)

debug.Text += "1 ";

debug.Text += "0 ";

}

debug.Text += "\n";

}

}

(nextPaint)

{

nextPaint = false;x1 = 0;x2 = 0;x3 = 0;x4 = 0;y1 = 0;y2 = 0;y3 = 0;y4 = 0;gObj_ = panelNextShape.CreateGraphics();

gObj_.Clear(SystemColors.Control);(Shape.nextShape)

{1:

x1 = 3;

y1 = 1; //..

x2 = 4;

y2 = 1;

x3 = 3;

y3 = 2;

x4 = 4;

y4 = 2;;2:

x1 = 2;

y1 = 1; //..

x2 = 3;

y2 = 1;

x3 = 4;

y3 = 1;

x4 = 5;

y4 = 1;;3:

x1 = 3;

y1 = 1; //..

x2 = 3;

y2 = 2;

x3 = 2;

y3 = 2;

x4 = 4;

y4 = 2;;4:

x1 = 3;

y1 = 0; //..

x2 = 3;

y2 = 1;

x3 = 3;

y3 = 2;

x4 = 4;

y4 = 2;;5:

x1 = 3;

y1 = 0; //..

x2 = 3;

y2 = 1;

x3 = 3;

y3 = 2;

x4 = 2;

y4 = 2;;6:

x1 = 4;

y1 = 0; //..

x2 = 4;

y2 = 1;

x3 = 3;

y3 = 1;

x4 = 3;

y4 = 2;;7:

x1 = 2;

y1 = 0; //..

x2 = 2;

y2 = 1;

x3 = 3;

y3 = 1;

x4 = 3;

y4 = 2;;

}(Shape.nextShape != 0)

{

gObj_.FillRectangle(newLinearGradientBrush(newRectangle(x1 * 30, y1 * 30, 30, 30), Color.DarkRed, SystemColors.Control, LinearGradientMode.BackwardDiagonal), x1 * 30, y1 * 30, 30, 30);

gObj_.FillRectangle(newLinearGradientBrush(newRectangle(x2 * 30, y2 * 30, 30, 30), Color.DarkRed, SystemColors.Control, LinearGradientMode.BackwardDiagonal), x2 * 30, y2 * 30, 30, 30);

gObj_.FillRectangle(newLinearGradientBrush(newRectangle(x3 * 30, y3 * 30, 30, 30), Color.DarkRed, SystemColors.Control, LinearGradientMode.BackwardDiagonal), x3 * 30, y3 * 30, 30, 30);

gObj_.FillRectangle(newLinearGradientBrush(newRectangle(x4 * 30, y4 * 30, 30, 30), Color.DarkRed, SystemColors.Control, LinearGradientMode.BackwardDiagonal), x4 * 30, y4 * 30, 30, 30);

}

}(fullPaint)

{

gObj.Clear(Color.LightGray);

(int x = 0; x < 10; x++)

{(int y = 0; y < 19; y++)

{(table[x, y] == true)

{px1 = x * 30;px2 = y * 30;.FillRectangle(newLinearGradientBrush(newRectangle(px1, px2, 30, 30), Color.DarkRed, Color.Gainsboro, LinearGradientMode.BackwardDiagonal), px1, px2, 30, 30);

}

}

}

//fullPaint = false;

}

{x = 0;y = 0;(int i = 0; i < 4; i++)

{

x = Shape.coord[i, 0];

y = Shape.coord[i, 1];(x == 0 && y == 0);

gObj.FillRectangle(newLinearGradientBrush(newRectangle(x * 30, y * 30, 30, 30), Color.DarkRed, Color.Gainsboro, LinearGradientMode.BackwardDiagonal), x * 30, y * 30, 30, 30);

}

}

}button1_Click(object sender, EventArgs e)

{

}Form1_KeyDown(object sender, KeyEventArgs e)

{(e.KeyCode == Keys.Left)

{(game == "Build")

Shape_.left();

Tanks_.Tank_.leftRot();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.Right)

{(game == "Build")

Shape_.right();

Tanks_.Tank_.rightRot();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.Space)

{(game == "Build")

{.space = true;

Shape_.down();

}

{

Tanks_.Tank_.push();

}

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.Down)

{(game == "Build").rotate_left();

Tanks_.Tank_.goBack();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.Up)

{(game == "Build").rotate_right();

Tanks_.Tank_.go();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.W)

{

Tanks_.Tank_1.go();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.A)

{

Tanks_.Tank_1.leftRot();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.D)

{

Tanks_.Tank_1.rightRot();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.S)

{

Tanks_.Tank_1.goBack();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.ControlKey)

{

Tanks_.Tank_1.push();

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.Q)

{

Tanks_.Tank_1.cheatUse("l");

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.E)

{

Tanks_.Tank_1.cheatUse("r");

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.End)

{

Tanks_.Tank_.cheatUse("r");

e.SuppressKeyPress = true;

}(e.KeyCode == Keys.ShiftKey)

{

Tanks_.Tank_.cheatUse("l");

e.SuppressKeyPress = true;

}

}Form1_KeyPress(object sender, KeyPressEventArgs e)

{

}Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)

{(e.KeyCode)

{.Left:.Right:.Down:.Space:.Up:.LShiftKey:.Shift:.ShiftKey:.RShiftKey:.Alt:.ControlKey:

e.IsInputKey = true;;

}

}checkBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)

{(e.KeyCode)

{.Left:.Right:.Down:.Space:.Up:.LShiftKey:.Shift:.ShiftKey:.RShiftKey:.Alt:.ControlKey:

e.IsInputKey = true;;

}

}checkBox1_CheckedChanged(object sender, EventArgs e)

{(Pause.Checked)

{

Build_.thr.Suspend();.isPaused = true;

label5.Visible = true;

PanelPad.Visible = false;

checkBox1.Enabled = false;

}

{

Build_.thr.Resume();

fullPaint = true;.isPaused = false;

PanelPad.Visible = true;

label5.Visible = false;

checkBox1.Enabled = true;

}

}radioButton2_CheckedChanged(object sender, EventArgs e)

{

 

}checkBox1_CheckedChanged_1(object sender, EventArgs e)

{

startButton();

}startButton()

{gObj = PanelPad.CreateGraphics();(checkBox1.Checked)

{

MF = (MainWindow)Form.ActiveForm;mode = 0;(radioButton1.Checked)

mode = 1;(radioButton2.Checked)

mode = 2;(radioButton3.Checked)

mode = 3;_.Start(mode);

checkBox1.Text = "Stop";

groupBox7.Enabled = false;.Text = Build.Score.ToString();

label2.Text = Build.LinesRemoved.ToString();

label3.Text = Build.Level.ToString();

label4.Text = Build.Shapes.ToString();

}

{

Build_.thr.Abort();

gObj.Clear(Color.LightGray);

checkBox1.Text = "Start";

groupBox7.Enabled = true;

}

}MainWindow_FormClosing(object sender, FormClosingEventArgs e)

{(game == "Build")(Build_.thr != null)(Build_.thr.ThreadState == System.Threading.ThreadState.Suspended)

{

Build_.thr.Resume();

Build_.thr.Abort();

}

Build_.thr.Abort();(game == "Tanks"&& Tanks_ != null)(Tanks_.thr != null)(Tanks_.thr.ThreadState == System.Threading.ThreadState.Suspended)

{

Tanks_.thr.Resume();

Tanks_.thr.Abort();

thrTime.Resume();

thrTime.Abort();

label11.Text = "0";

}

{

Tanks_.thr.Abort();

thrTime.Abort();

label11.Text = "0";

}

}button1_Click_1(object sender, EventArgs e)

{(Build_.thr != null)(Build_.thr.ThreadState == System.Threading.ThreadState.Suspended)

{

Build_.thr.Resume();

Build_.thr.Abort();

}

Build_.thr.Abort();

game = "Build";

checkBox1.Enabled = true;

checkBox1.Checked = false;

Pause.Checked = false;.Visible = false;

RightPanel.Visible = false;

PanelPad.Visible = false;

PanelMenu.Visible = true;

}button2_Click(object sender, EventArgs e)

{

game = "Build";

PanelMenu.Visible = false;

PanelPad.Visible = true;