// Функция, здесь перегруженная, pапускает переназначение координат от хвоста до первого элемента за головой. сделана, чтобы обозначить логику происходящего public override void Set_New_Coords() { m_Last_Position = Location; Location = Next_Block.Location; Next_Block.Set_New_Coords(); }
} // the event of exit private void Start_Botton_Click(object sender, EventArgs e) // the event of start { if (Restart == true) { Start(); Start_Botton.Text = "End"; } else if (Restart == false) { End(); Main_Screen.Refresh(); Next_Block.Refresh(); Start_Botton.Text = "Start"; MessageBox.Show("Game Over!"); pause = false; Pause_Lable.Text = "Pause"; } }
public void Show_Next_Block() // the function to show the state of next block { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { next_block_graph[i, j] = 0; } } int The_color = nextblock.color; if (nextblock.TypeNumber == 1) { next_block_graph[2, 3] = The_color; next_block_graph[3, 3] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 4] = The_color; } else if (nextblock.TypeNumber == 2) { next_block_graph[1, 2] = The_color; next_block_graph[2, 2] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 3] = The_color; } else if (nextblock.TypeNumber == 3) { next_block_graph[1, 3] = The_color; next_block_graph[2, 3] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 3] = The_color; } else if (nextblock.TypeNumber == 4) { next_block_graph[1, 2] = The_color; next_block_graph[2, 2] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[4, 2] = The_color; } else if (nextblock.TypeNumber == 5) { next_block_graph[2, 2] = The_color; next_block_graph[2, 3] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 3] = The_color; } else if (nextblock.TypeNumber == 6) { next_block_graph[2, 2] = The_color; next_block_graph[4, 3] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 3] = The_color; } else if (nextblock.TypeNumber == 7) { next_block_graph[4, 2] = The_color; next_block_graph[2, 3] = The_color; next_block_graph[3, 2] = The_color; next_block_graph[3, 3] = The_color; } Graphics g0 = Next_Block.CreateGraphics(); g0.DrawLine(new Pen(black), new PointF(0, 0), new PointF(0, 80)); g0.DrawLine(new Pen(black), new PointF(0, 0), new PointF(80, 0)); g0.DrawLine(new Pen(black), new PointF(0, 80), new PointF(80, 80)); g0.DrawLine(new Pen(black), new PointF(80, 0), new PointF(80, 80)); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (next_block_graph[i, j] == 0) { g0.FillRectangle(white, Shape[i, j]); } else if (next_block_graph[i, j] == 1) { g0.FillRectangle(black, Shape[i, j]); } else if (next_block_graph[i, j] == 2) { g0.FillRectangle(red, Shape[i, j]); } else if (next_block_graph[i, j] == 3) { g0.FillRectangle(orange, Shape[i, j]); } else if (next_block_graph[i, j] == 4) { g0.FillRectangle(yellow, Shape[i, j]); } else if (next_block_graph[i, j] == 5) { g0.FillRectangle(green, Shape[i, j]); } else if (next_block_graph[i, j] == 6) { g0.FillRectangle(cyan, Shape[i, j]); } else if (next_block_graph[i, j] == 7) { g0.FillRectangle(blue, Shape[i, j]); } else if (next_block_graph[i, j] == 8) { g0.FillRectangle(purple, Shape[i, j]); } } } }