나는 체스 게임의 작은 변종을 창문 형태 C#을 사용하여 만들 것을 배우고있다. 게임은 양면의 졸 뿐이며, 나는 보드를 뽑아 거기에 조각들을 조직했다. 그러나 나는 정직하게 시작하는 법을 모른다. 조각을 마우스로 클릭 한 다음 이동하려는 위치를 클릭하여 이동을 구현합니다.체스 게임에서 동작을 구현하는 방법은 무엇입니까?
검은 전당포가 조각 이름이 참조로, 흰색 폰은 보드 여기
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIchess
{
public partial class Form1 : Form
{
static System.Drawing.Bitmap piece = AIchess.Properties.Resources.piece;
ChessPiece Piece = new ChessPiece(piece, ChessColor.Black);
static System.Drawing.Bitmap pieceW = AIchess.Properties.Resources.pieceW;
ChessPiece PieceW = new ChessPiece(pieceW, ChessColor.White);
Square[,] square = new Square[8, 8];
public Form1()
{
InitializeComponent();
int i, j;
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
{
this.square[i, j] = new Square();
this.square[i, j].BackColor = System.Drawing.SystemColors.ActiveCaption;
this.square[i, j].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.square[i, j].Location = new System.Drawing.Point(57 + i * 60, 109 + j * 60);
this.square[i, j].Name = i.ToString()+j.ToString();
this.square[i, j].Size = new System.Drawing.Size(60, 60);
this.square[i, j].TabIndex = 2;
this.square[i, j].TabStop = false;
this.Controls.Add(this.square[i, j]);
if (j == 1)
{
this.square[i, j].Image = piece;
this.square[i, j].AllocatedBy = "black";
}
if (j == 6)
{
this.square[i, j].Image = pieceW;
this.square[i, j].AllocatedBy = "white";
}
if (((i+j) % 2) ==0)
this.square[i, j].BackColor = Color.RoyalBlue;
else
this.square[i, j].BackColor = Color.LightBlue;
}
}
}
}
public enum ChessColor
{
White,
Black,
};
class ChessPiece
{
private Image DisplayedImage;
private ChessColor DisplayedColor;
private Point CurrentSquare;
public ChessPiece(Image image, ChessColor color)
{
DisplayedImage = image;
DisplayedColor = color;
}
}
class Square:PictureBox
{
private bool color;
public string AllocatedBy;
}
}
32 비트 비트 맵을 사용하세요 무엇합니까처럼'ChessPiece' 클래스보기? –
공개 열거 형 ChessColor { 흰색, 검정, }}; 클래스 체스 조각 { 개인 이미지 DisplayedImage; 비공개 ChessColor DisplayedColor; 개인 포인트 CurrentSquare; 공개 체스 조각 (이미지 이미지, 체스 컬러) { DisplayedImage = image; DisplayedColor = color; } } –
아마 이걸 [gamedev.stackexchange.com] (http://gamedev.stackexchange.com) – James