public RectangleCoordinate(RectangleDimension dim) { this.TopRightXPos = dim.x; this.TopRightYPos = dim.y; this.BottomLeftXPos = (dim.width + dim.x); this.BottomLeftYPos = (dim.height + dim.y); }
// copy constructor public RectangleDimension(RectangleDimension copy) { this.width = copy.width; this.height = copy.height; this.x = copy.x; this.y = copy.y; }
/* * Given (x,y) coordinates this will return what position from {1,..,10} * the coordinate is in */ public int MouseInCardPosition(int x, int y, RectangleDimension playerBox) { int relativeX = x - playerBox.x; int relativeY = y - playerBox.y; int column = relativeX / 71; int row = relativeY / 96; int[,] matrix = { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 } }; column = (column == 5) ? 4 : column; // the max 5 is column 4 not 5 see the explenation on the next line row = (row == 2) ? 1 : row; // if relativeY = 192 then 192/96 = 2 but the row is really 1 since thats the second row return(matrix[row, column]); }
public RectangleType(RectangleDimension dim) { rectCoord = new RectangleCoordinate(dim); rectDim = new RectangleDimension(dim); }
// constructors public RectangleType(RectangleCoordinate coord) { rectCoord = new RectangleCoordinate(coord); rectDim = new RectangleDimension(coord); }
private void DrawCardOnPlayer(RectangleDimension playerBox, int cardPosition, System.Drawing.Bitmap picture) { Coordinate coord = PositionCoordinates(cardPosition); slate.DrawImage(picture, playerBox.x + coord.x, playerBox.y + coord.y, 71, 96); }