I am making a chess game in c sharp by using a code from our text book. but this code is not working. can anybody please be kind enough to help me make this code work.. I shall be very thankful. when i run this program in c sharp,console application,the output screen appears only for 1 sec and disappears automatically.this is the code:-
using System;
using System.Drawing;
public class ChessPiece
{
public enum Types
{
KING,
QUEEN,
BISHOP,
KNIGHT,
ROOK,
PAWN,
}
private int currentType;
private Bitmap pieceImage;
private Rectangle targetRectangle = new Rectangle(0, 0, 75, 75);
public ChessPiece(int type, int xLocation, int yLocation, Bitmap sourceImage)
{
currentType = type;
targetRectangle.X = xLocation;
targetRectangle.Y = yLocation;
pieceImage = sourceImage.Clone(new Rectangle(type * 75, 0, 75, 75),
System.Drawing.Imaging.PixelFormat.DontCare);
}
public void Draw(Graphics graphicsObject)
{
graphicsObject.DrawImage(pieceImage, targetRectangle);
}
public Rectangle GetBounds()
{
return targetRectangle;
}
public void SetLocation(int xLocation, int yLocation)
{
targetRectangle.X = xLocation;
targetRectangle.Y = yLocation;
console.readline();
}
}
Jignesh TrivediPosted Apr 23, 2012, 11:51 PM
I dont what is problem in your code but please refer
http://harmoniaphilosophica.wordpress.com/2011/09/28/how-to-develop-a-chess-program-for-2jszrulazj6wq-23/
i think it related to u.
hope this help.
Felipe RamosPosted Apr 23, 2012, 10:01 PM
mariam hameedPosted Apr 24, 2012, 3:13 AM
MuthuMari MPosted Apr 23, 2012, 11:43 PM
felipe ramos said right , am going to tell the same thing
public void SetLocation(int xLocation, int yLocation)
{
targetRectangle.X = xLocation;
targetRectangle.Y = yLocation;
}
you have to use this console.readline(); at the end of the main().
static void Main() {// your code is here.mariam hameedPosted Apr 23, 2012, 11:27 PM