当前位置:编程学习 > C#/ASP.NET >>

C# 五子棋代码 我输赢判断不会 求大神帮忙把代码写全~ 横向竖向和斜向判断

跪求~ 新手娱乐 求解答~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace fivechess
{

    public partial class Form1 : Form
    {
     
        public Form1()
        {
            InitializeComponent();
        }
        int a = 0;
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        //棋盘
        private void Form1_Paint(object sender, PaintEventArgs e)
        {

            for (int i = 0; i < 17; i++)
            {
                drawlines(i * 30);
                drawlineh(i * 30);
            }

        }
        //竖线
        public void drawlines(int i)
        {
            Graphics g = this.CreateGraphics();
            Pen blackPen = new Pen(Color.Black, 2);
            Point[] Spacing = { new Point(20 + i, 30), new Point(20 + i, 510) };
            g.DrawLines(blackPen, Spacing);
        }

        //横线
        public void drawlineh(int i)
        {
            Graphics g = this.CreateGraphics();
            Pen blackPen = new Pen(Color.Black, 2);
            Point[] Rowspacing = { new Point(20, 30 + i), new Point(500, 30 + i) };
            g.DrawLines(blackPen, Rowspacing);
        }
        //X,Y坐标
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            //this.Text = "X:" + e.X + ",Y:" + e.Y;



        }
        //棋子
        private void AddPicture(int x, int y)
        {
            PictureBox hz = new PictureBox();
            hz.Image = global::WindowsFormsApplication20.Properties.Resources.Copy_of_blackstone;
            hz.SizeMode = PictureBoxSizeMode.Zoom;
            hz.BackColor = Color.Transparent;
            hz.Location = new Point(x, y);
            hz.Width = 27;
            hz.Height = 27;
            this.Controls.Add(hz);

        }
        private void AddPicture1(int x1, int y1)
        {
            PictureBox bz = new PictureBox();
            bz.Image = global::WindowsFormsApplication20.Properties.Resources.Copy_of_whitestone;
            bz.SizeMode = PictureBoxSizeMode.Zoom;
            bz.BackColor = Color.Transparent;
            bz.Location = new Point(x1, y1);
            bz.Width = 27;
            bz.Height = 27;
            this.Controls.Add(bz);

        }

        //落子
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            a++;

            if (a % 2 == 0)
            {
                if (e.X < 502 && e.X > 19 && e.Y > 29 && e.Y < 511)
                    AddPicture1((e.X - 20 + 15) / 30 * 30 + 5, (e.Y - 30 + 15) / 30 * 30 + 15);
                label1.Visible = true;
                label2.Visible = false;
            }
            else
            {
                if (e.X < 502 && e.X > 19 && e.Y > 29 && e.Y < 511)
                    AddPicture((e.X - 20 + 15) / 30 * 30 + 5, (e.Y - 30 + 15) / 30 * 30 + 15);
                label2.Visible = true;
                label1.Visible = false;
            }


        }

            }
        }
c# 作业 --------------------编程问答-------------------- 五子棋的代码 太多了。

按照你的代码写,还真没有时间啊 

http://www.cnblogs.com/yeagen/archive/2010/08/14/1799461.html
也可以去下载下载别人的参考一下。 --------------------编程问答--------------------
新手实在是对这种判断无力,各种代码也看过 可是还是无法实现 --------------------编程问答-------------------- 这代码比较清晰,可以看看

五子棋
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,