mariam hameed

mariam hameed

  • NA
  • 12
  • 19.4k

Help in code developed using c sharp.

Apr 23 2012 12:45 PM
HI,

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();
    }
}



Answers (5)