C#Winform–俄罗斯方块
作者心得
好吧,我承认,这是一个面向过程弄的
虽然打算面向对象,但技术不成熟,弄着弄着,就变成面向对象了
代码。。。。数量直接指数爆炸,我怕这个页面都放不下
另外,第一次使用了第三方控件,美滋滋
部分核心源代码
(太多!太多了!也就只能放下一个地图)
(其他面向过程代码真的太多了)
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;
using CCWin;
namespace ZJELSFK
{
public partial class Form1 : CCSkinMain
{
public Form1()
{
InitializeComponent();
}
Button[,] map = new Button[15, 25];
bool start = true;
char fxp = 'o';
int x = 4;
int y = 0;
int sco = 0;
string create = "O";
string create_next = "O";
bool number = true;
bool change = false;
bool end = false;
Random random = new Random();
private void Form1_Load(object sender, EventArgs e)//创建地图
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 20; j++)
{
Button map_template = new Button();
map_template.Size = new Size(20, 20);
map_template.BackColor = Color.White;
map_template.Location = new Point(i * 20 + 20, j * 20);
map[i, j] = map_template;
Controls.Add(map[i, j]);
}
}
for (int i = 0; i < 21; i++)
{
Button map_template2 = new Button();
map_template2.Size = new Size(20, 20);
map_template2.BackColor = Color.Black;
map_template2.Location = new Point(0, i * 20);
Controls.Add(map_template2);
Button map_template3 = new Button();
map_template3.Size = new Size(20, 20);
map_template3.BackColor = Color.Black;
map_template3.Location = new Point(220, i * 20);
Controls.Add(map_template3);
if (i < 12)
{
Button map_template4 = new Button();
map_template4.Size = new Size(20, 20);
map_template4.BackColor = Color.Black;
map_template4.Location = new Point(i * 20, 400);
Controls.Add(map_template4);
}
}
create = random_blocks();
create_next = random_blocks(); //初始化随机方块
}
效果截图
作者的话
这个俄罗斯方块还挺好玩的,其实打算弄下去,改进为 面相对象,但是当我有这个想法的时候,已经开发Asp项目,放弃了winform,不想再弄这玩意儿了,哎!