那个exe出来有什么意思???!!!!!
给予支持!
不好意思好久没上论坛来了,现在就发原码
// ***************************************************************
// Form1 version: 1.0 ? finished date: 03/28/2006
// -------------------------------------------------------------
// Email:espricle@hotmail.com or dai--yl@163.com
// -------------------------------------------------------------
// Copyright (C) 2006 - All Rights Reserved
// ***************************************************************
// made by moderndai
// ***************************************************************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
namespace 五子棋
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
int count=0;
Pen bluepen=new Pen(Color.Blue);
SolidBrush brush=new SolidBrush(Color.BlanchedAlmond);
SolidBrush whitebrush=new SolidBrush(Color.White);
SolidBrush blackbrush=new SolidBrush(Color.Black);
private System.Windows.Forms.MenuItem menuItem6;
int[,]xy=new int[15,15];
public void F_QiPan()
{
Graphics g=CreateGraphics();
g.FillRectangle(brush,0,0,700,700);
for (int x_=30;x_<=450;x_+=30)
{
g.DrawLine(bluepen,x_,30,x_,450);
}
for (int y_=30;y_<=450;y_+=30)
{
g.DrawLine(bluepen,30,y_,450,y_);
}
}
public void QiPan()
{
Graphics g=CreateGraphics();
g.FillRectangle(brush,0,0,700,700);
for (int i=0;i<15;i++)
{
for (int j=0;j<15;j++)
{
xy[i,j]=0;
}
}
for (int x_=30;x_<=450;x_+=30)
{
g.DrawLine(bluepen,x_,30,x_,450);
}
for (int y_=30;y_<=450;y_+=30)
{
g.DrawLine(bluepen,30,y_,450,y_);
}
}
public static int XPosition(int x_position)
{
int xx;
if (x_position%30>15)
{
xx=(int)(x_position/30);
x_position=(x_position/30+1)*30;
}
else
{
xx=(int)(x_position/30);
x_position=xx*30;
}
return x_position;
}
public static int YPosition(int y_position)
{
int yy;
if (y_position%30>15)
{
yy=(int)(y_position/30);
y_position=(yy+1)*30;
}
else
{
yy=(int)(y_position/30);
y_position=yy*30;
}
return y_position;
}
public void X_QiZi(int x,int y)
{
Graphics g=CreateGraphics();
x=XPosition(x)/30-1;
y=YPosition(y)/30-1;
if (xy[x,y]==0)
{
if (count==0)
{
count=1;
xy[x,y]=1;
}
else if (count==1)
{
count=0;
xy[x,y]=-1;
}
}
else
return;
}
public void QiZi()
{
int x1,y1;
Graphics g=CreateGraphics();
for (int i=0;i<15;i++)
{
for (int j=0;j<15;j++)
{
x1=30*i+15;
y1=30*j+15;
if (xy[i,j]==1)
{
g.FillEllipse(blackbrush,x1,y1,30,30);
}
else if(xy[i,j]==-1)
{
g.FillEllipse(whitebrush,x1,y1,30,30);
}
}
}
}
public int H_Winner(int num1)
{
num1++;
if (num1>4)
{
MessageBox.Show("黑子获胜,按确定重新开始");
QiPan();
}
return num1;
}
public int B_Winner(int num2)
{
num2++;
if (num2>4)
{
MessageBox.Show("白子获胜,按确定重新开始");
QiPan();
}
return num2;
}
public void Win(int x2,int y2)//嬴的条件
{
x2=XPosition(x2)/30-1;
y2=YPosition(y2)/30-1;
int number1=1,number2=1,number3=1,number4=1;
for (int i=x2,j=y2-4;j<y2+5;j++)//判断所下的子的列有没有5个是一样的
{
if (j<=-1)
{
j=-1;
}
else if (j<15)
{
if (j<14)
{
if(xy[i,j]==xy[i,j+1]&&xy[i,j]!=0)
{
if (xy[i,j]==1)
{
number1=H_Winner(number1);
}
else
{
number1=B_Winner(number1);
}
}
else
number1=1;
}
else
number1=1;
}
else
number1=1;
}
for (int i=x2-5,j=y2;i<x2+4;i++)//判断所下的子的行的有没有5个子连着是一样的
{
if (i<0)
{
i=-1;
}
else if (i<15)
{
if (i<14)
{
if (xy[i,j]==xy[i+1,j]&&xy[i,j]!=0)
{
if (xy[i,j]==1)
{
number2=H_Winner(number2);
}
else
{
number2=B_Winner(number2);
}
}
else
number2=1;
}
else
number2=1;
}
else
number2=1;
}
for (int j=y2-4,i=x2-4;i<x2+5;j++,i++)//判断所下的子斜着的有没有5个连续一样的
{
if (i<=-1||j<=-1)
{
while(i!=-1||j!=-1)
{
i++;
j++;
if (i>=-1&&j>=-1)
{
break;
}
}
}
else if (i>14||j>14)
{
number3=1;
break;
}
else
{
if (i<14&&j<14)
{
if(xy[i,j]==xy[i+1,j+1]&&xy[i,j]!=0)
{
if (xy[i,j]==1)
{
number3=H_Winner(number3);
}
else
{
number3=B_Winner(number3);
}
}
}
else
{
number3=1;
break;
}
}
}
for (int j=y2+4,i=x2-4;i<x2+5;j--,i++)
{
if (i<=-1||j>=15)
{
while (i!=-1||j!=15)
{
i++;
j--;
if(i>=-1&&j<=15)
{
break;
}
}
}
else if(i>14||j<0)
{
number4=1;
break;
}
else
{
if (i<14&&j>0)
{
if(xy[i,j]==xy[i+1,j-1]&&xy[i,j]!=0)
{
if (xy[i,j]==1)
{
number4=H_Winner(number4);
}
else
{
number4=B_Winner(number4);
}
}
else
number4=1;
}
else
{
number4=1;
break;
}
}
}
}
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;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem6});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuItem4});
this.menuItem1.Text = "菜单";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "重新开始";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "退出";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem5});
this.menuItem2.Text = "帮助";
//
// menuItem5
//
this.menuItem5.Index = 0;
this.menuItem5.Text = "游戏说明";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Text = "联系方式";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(692, 645);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
this.MouseEnter += new System.EventHandler(this.Form1_MouseEnter);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
QiPan();
}
private void Form1_MouseEnter(object sender, System.EventArgs e)
{
F_QiPan();
QiZi();
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.X<15||e.X>465||e.Y<15||e.Y>465)
{
return;
}
else
{
X_QiZi(e.X,e.Y);
QiZi();
Win(e.X,e.Y);
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
MessageBox.Show("\n谁先将自己手中颜色的棋子先连成5个就算嬴\n","游戏说明",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
MessageBox.Show("dai--yl@163.com或者espricle@hotmail.com","联系方式",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}