盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

c#写的5子棋程序,供学习WinForms的鼠标事件与使用GDI+

时间:2024/12/11作者:未知来源:盾怪网教程人气:

[摘要]y+i>14)continue;elseif(chessTable[(y+i)*15+x+i] == thisTurn)isFive.Push((y+i)*15+x+i);if(isFive....
y+i>14)

{

continue;

}

else

{

if(chessTable[(y+i)*15+x+i] == thisTurn)

{

isFive.Push((y+i)*15+x+i);

if(isFive.Count == 5)

{

MessageBox.Show("Game Over","Notes",MessageBox.OK);

ReSetGame();

return;

}

}

else

{

isFive.Clear();

}

}

}

isFive.Clear();

}

private void ReSetGame()

{

//reset game

nextTurn = bTurn;

for(int i=0;i<225;i++)

{

chessTable[i] = 0;

}

this.Invalidate();

}

private int GetRectID(Point p)

{

//get witch rectangle click

for(int i = 0;i < 225;i++)

{

if(pointSquares[i].Contains( p ))

{

return i;

}

}

return -1;

}

private void OnRButtonDown(Point p)

{

//regret chess

int nPos,x,y;

if(chessIndex.Count != 0)

{

nPos = (int)chessIndex.Pop();

x = nPos%15;

y = nPos/15;

chessTable[nPos] = 0;

nextTurn = (int)chessIndex.Pop();

this.Invalidate(new Rectangle(new Point(8+x*20,5+y*20),new Size(20,20)));

}

}

private void DrawBlack(Graphics g,int nPos)

{

//draw Black chess

int x,y;

x = nPos%15;

y = nPos/15;

imageListbw.DrawImage(g,8+20*x,5+20*y,20,20,0,0);

}

private void DrawWhite(Graphics g,int nPos)

{

//draw White chess

int x,y;

x = nPos%15;

y = nPos/15;

imageListbw.DrawImage(g,8+20*x,5+20*y,20,20,0,1);

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

public override void Dispose()

{

base.Dispose();

components.Dispose();

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof(FiveForm));

this.components = new System.ComponentModel.Container ();

this.imageListbw = new System.WinForms.ImageList ();

//@this.TrayHeight = 90;

//@this.TrayLargeIcon = false;

//@this.TrayAutoArrange = true;

//@imageListbw.SetLocation (new System.Drawing.Point (7, 7));

imageListbw.ImageSize = new System.Drawing.Size (20, 20);

imageListbw.ImageStream = (System.WinForms.ImageListStreamer) resources.GetObject ("imageListbw.ImageStream");

imageListbw.ColorDepth = System.WinForms.ColorDepth.Depth8Bit;

imageListbw.TransparentColor = System.Drawing.Color.Yellow;

this.Text = "FiveForm";

this.MaximizeBox = false;

this.AutoScaleBaseSize = new System.Drawing.Size (6, 14);

this.BorderStyle = System.WinForms.FormBorderStyle.FixedSingle;

this.BackgroundImage = (System.Drawing.Image) resources.GetObject ("$this.BackgroundImage");

this.TransparencyKey = System.Drawing.Color.White;

this.ClientSize = new System.Drawing.Size (314, 311);

}

/// <summary>

/// The main entry point for the application.

/// </summary>

public static int Main(string[] args)

{

Application.Run(new FiveForm());

return 0;

}

}

}




关键词:c#写的5子棋程序,供学习WinForms的鼠标事件与运用GDI+




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版