【橙子】C#Winform--俄罗斯方块

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,不想再弄这玩意儿了,哎!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
C#做的俄罗斯方块游戏using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Xml; using System.IO; using System.Security.Cryptography; using System.Text; using System.Runtime.Serialization.Formatters.Binary; namespace RussiaBlock { public class MainForm : System.Windows.Forms.Form { #region 变量 private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Timer timer1; private Block block; private Block nextBlock; private int nextShapeNO; private bool paused; private DateTime atStart; private DateTime atPause; private TimeSpan pauseTime; private System.Windows.Forms.Panel panel3; private System.Windows.Forms.TextBox textBox1; private ControlForm sform; private Keys[] keys; private System.Windows.Forms.Label label4; private int level; private int startLevel; private bool trans; private int rowDelNum; private bool failed; private System.Windows.Forms.Label label5; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.MenuItem menuItem6; private AxWMPLib.AxWindowsMediaPlayer axMediaPlayer1; private System.Windows.Forms.MenuItem menuItem7; private System.ComponentModel.IContainer components; #endregion public MainForm() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(component

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值