标题:自己写的五子棋游戏
只看楼主
xylzk2004
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-5-12
得分:0 

那个exe出来有什么意思???!!!!!

2006-05-12 16:31
梦幻情缘
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:769
专家分:20
注 册:2005-4-4
得分:0 

给予支持!

2006-05-12 17:59
yahoocs
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-8
得分:0 
不错支持!!
2006-05-12 18:36
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8074
专家分:6657
注 册:2005-11-7
得分:0 

有不好的地方,那就是把鼠标移出再移进就没有棋子了


本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-05-13 13:06
花自飘零水自流
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-4-28
得分:0 
是的啊`!
把源代码贴出来分享下啊`!~??
或者就发到我邮箱里好吗?
谢谢楼主!hubaiwen@163.com

切记人生四千万:千万不要去触碰脆弱的爱情,千万不要虚度年华,千万要爱护自己, 千万要懂得珍惜 !
2006-05-13 15:38
linsoo
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2006-4-29
得分:0 
没有源代码发了有毛用,我们是来学习的,不是来Show或看别人Show的,不舍得发源代码就表发。。。
2006-05-14 15:41
moderndai
Rank: 1
等 级:新手上路
帖 子:104
专家分:0
注 册:2006-1-25
得分:0 

不好意思好久没上论坛来了,现在就发原码
// ***************************************************************
// 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);
}
}
}


ROCK AND ROCK PROGRAMING dai--yl@&&espricle@
2006-05-14 18:52
theangles
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-3-4
得分:0 
好啊
2007-04-07 16:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-53658-1-1.html




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

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