设计界面如下:(如有不足,欢迎批评)
运行效果如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 别踩白块
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/*需求分析:
1.创建游戏区
2.游戏区每行4个,
3.实现每行随机白块与黑块
4.点击黑块得分+1
5.点击白块游戏结束
*/
Random r = new Random();
//创建游戏区
Panel bg = new Panel();
//创建白块与黑块
Timer greatkuai = new Timer();
//控制块下落
Timer xl = new Timer();
//记录分数
int count = 0;
Label defen = new Label();
private void Form1_Load(object sender, EventArgs e)
{
//this.FormBorderStyle = FormBorderStyle.None;
this.Size = new Size(500,700);
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width/2-this.Width/2,Screen.PrimaryS