| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 734 人关注过本帖
标题:制作方块出了问题
只看楼主 加入收藏
h19891338
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-5-11
收藏
 问题点数:0 回复次数:2 
制作方块出了问题
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace tetris
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private bool[,] struArr = new bool[5, 5];
        Color blockColor = Color.Red;
        private void label1_Paint(object sender, PaintEventArgs e)
        {
            Graphics gp = e.Graphics;
            Pen p = new Pen(Color.White);
            for (int i = 0; i < 155; i = i + 31)//0 not 1
            {
                gp.DrawLine(p, 1, i, 155, i);
            }
            for (int i = 0; i < 155; i = i + 31)
            {
                gp.DrawLine(p, i, 1, i, 155);
            }
        }

        private void label1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            
                return;
            
            int xPos, yPos;
            xPos = e.X / 31;
            yPos = e.Y / 31;
            struArr[xPos, yPos] = !struArr[xPos, yPos];

            bool b = struArr[xPos, yPos];
            Graphics gp = label1.CreateGraphics();
            SolidBrush s = new SolidBrush(b ? blockColor : Color.Black);
            gp.FillRectangle(s, 31 * xPos + 1, 31 * yPos + 1, 30, 30);
            gp.Dispose();
        }
    }
}                                                                                                                当你移动鼠标时
      回自动画黑线
  不知哪儿错了
如附件所示

QQ截图未命名.rar (642 Bytes)
搜索更多相关主题的帖子: using 方块 System public private 
2008-05-13 19:54
blueskyss
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:81
专家分:0
注 册:2008-2-19
收藏
得分:0 
你说的应该不是画线吧,是定制方块的第一步,改变颜色
也不是鼠标移动,而是点击,
我以前做过,视频bbs上有
2008-05-14 23:50
blueskyss
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:81
专家分:0
注 册:2008-2-19
收藏
得分:0 
private bool[,] struArr = new bool[5, 5];
        private Color blockColor = Color.Red;
 private void lblMode_Paint(object sender, PaintEventArgs e)
        {
            Graphics gp = e.Graphics;
            gp.Clear(Color.Black);
            Pen p = new Pen(Color.White);
            for (int i = 31; i < 155; i = i + 31)//竖线
            {
                gp.DrawLine(p, i, 1, i, 155);
            }
            for (int i = 31; i < 155; i = i + 31) //横线
            {
                gp.DrawLine(p, 1, i, 155, i);
            }

            SolidBrush s = new SolidBrush(blockColor);
            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    if (struArr[x, y])
                    {
                        gp.FillRectangle(s, 31 * x + 1, 31 * y + 1, 30, 30);
                    }
                }
            }
        }

        private void lblMode_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            else
            {
                int xPos, yPos;
                xPos = e.X / 31;
                yPos = e.Y / 31;
                struArr[xPos, yPos] = !struArr[xPos, yPos];
                bool b = struArr[xPos, yPos];
                Graphics gp = lblMode.CreateGraphics();
                SolidBrush s = new SolidBrush(b ? blockColor : Color.Black);
                gp.FillRectangle(s, 31 * xPos + 1, 31 * yPos + 1, 30, 30);
                gp.Dispose();
            }
        }
2008-05-14 23:51
快速回复:制作方块出了问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019041 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved