Пример #1
0
void DrawStartingBoard(string choice)
{
	int i;
	string letter[10]={"A","B","C","D","E","F","G","H","I","J"};
	if( StringEqual(choice,"y") ) { PlayNamedSound("Fanfare"); }
	for (i=0;i<=NUM_COLS;i++)
	{
		if (i!=NUM_COLS)
		{
			MovePen((i+1.3)*LG,GetWindowHeight()-LG);
			DrawTextString(IntegerToString(i));
		}
		MovePen((i+1)*LG,GetWindowHeight()-1.3*LG);
		DrawLine(0,(-NUM_ROWS)*LG);
	}
	for (i=0;i<=NUM_ROWS;i++)
	{
		if (i!=NUM_ROWS)
		{
			MovePen(LG/4,GetWindowHeight()-(11.1-i)*LG);
			DrawTextString(letter[9-i]);
		}
		MovePen(LG,GetWindowHeight()-(11.3-i)*LG);
		DrawLine((NUM_COLS)*LG,0);
	}
}
Пример #2
0
void MarkMiss(coord location)
{
	MovePen( (location.col+1)*LG,GetWindowHeight()-(location.row+1.3)*LG );
	DrawLine(LG,-LG);
	MovePen( (location.col+2)*LG,GetWindowHeight()-(location.row+1.3)*LG );
	DrawLine(-LG,-LG);
}
Пример #3
0
static void DrawWallUsingColor(wall w, string color)
{
	double startx = GetMazeLowerLeftX() + w.one.col * gWallLength;
	double starty = GetMazeLowerLeftY() + w.one.row * gWallLength;

	double wallLength = gWallLength;
	if (color == kMazeInvisibleColor) {
		wallLength *= 0.6;
	}

	SetPenColor(color);
	if (w.one.row == w.two.row) {
		startx += gWallLength;
		if (color == kMazeInvisibleColor)
			starty += gWallLength / 5;
		MovePen(startx, starty);
		DrawLine(0, wallLength);
	} else {
		starty += gWallLength;
		if (color == kMazeInvisibleColor)
			startx += gWallLength / 5;
		MovePen(startx, starty);
		DrawLine(wallLength, 0);
	}
}
Пример #4
0
void confirmComplete(double x1, double y1, double x2, double y2)//确认完成按钮函数
{
    MovePen(x1,y1);
    DrawLine(x2-x1,0);
    DrawLine(0,y2-y1);
    DrawLine(x1-x2,0);
    DrawLine(0,y1-y2);
    double distance1;
    double distance2;
    double X,Y;
    SetPenColor(RED);
    distance1=(x2-x1-GetStringWidth("输入完成"))/2;
    distance2=(y1-y2-GetStringWidth("输"))/2;
    MovePen(x1+distance1,y1-distance2);
    DrawString("输入完成");
    SetPenColor(BLACK);
    while(1)
    {
        while(!(WaitForEvent()==KEYDOWN)){}
        if(GetStruckKey() == VK_LBUTTON)
        {
            X = GetMouseX();
            Y = GetMouseY();
            if((X >= x1 && X <= x2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内
            {
                EatEgg();//吃掉完成键和信息输入框的蛋
                break;
            }
        }
    }

}
Пример #5
0
void DrawHighlight(buttonT & button) {
    MovePen(button.x + 2, button.y + button.height - 2);
    DrawLine(0, 4 - button.height);
    MovePen(button.x + 2, button.y + button.height - 2);
    DrawLine(button.width - 4, 0);
    MovePen(button.x + 3, button.y + button.height - 3);
    DrawLine(0, 0);
}
Пример #6
0
/* 
 * Function: DrawPlayerLabel
 * -------------------------
 * Labels player word list with specified name and draws a line underneath the label.
 * It also resets the player's score and word list count back to zero.
 */
static void DrawPlayerLabel(playerT player, string name)
{
    SetPenColor("Label Color");
    MovePen(gState.scoreBox[player].x, gState.scoreBox[player].y);
    DrawLine(gState.scoreBox[player].w , 0);
    SetFont(SCORE_FONT);
    SetPointSize(SCORE_FONT_SIZE);
    MovePen(gState.scoreBox[player].x, gState.scoreBox[player].y + GetFontDescent());
    DrawTextString(name);
    gState.scores[player] = gState.numWords[player] = 0;
}
Пример #7
0
/* Function: DrawFilledCircleWithLabel
 * Usage:  DrawFilledCircleWithLabel(center, .25, "Green", "You are here");
 * -----------------------------------------------------------------------
 * Uses facilities from extgraph to draw a circle filled with
 * color specified. The circle is centered at the given coord has the
 * specified radius.  A label is drawn to the right of the circle.
 * If you don't want a label, pass the empty string.
 */
void DrawFilledCircleWithLabel(coordT center, double radius, string color, string label)
{
    MovePen(center.x + radius, center.y);
    SetPenColor(color);
    StartFilledRegion(1.0);
    DrawArc(radius, 0, 360);
    EndFilledRegion();
    MovePen(center.x + radius, center.y);
    SetFont("Helvetica");
    SetPointSize(FONT_SIZE);
    DrawTextString(label);
}
Пример #8
0
void DrawPathfinderNode(pointT center, string color, string label) {
	MovePen(center.x + NODE_RADIUS, center.y);
	SetPenColor(color);
	StartFilledRegion(1.0);
	DrawArc(NODE_RADIUS, 0, 360);
	EndFilledRegion();
	if (!label.empty()) {
		MovePen(center.x + NODE_RADIUS + 2, center.y + 0.4 * GetFontAscent());
		SetFont("Helvetica");
		SetPointSize(FONT_SIZE);
		DrawTextString(label);
	}
}
Пример #9
0
void Maze::drawMark(pointT p, string color)
{
	if (!pointInBounds(p))
		Error("Point is not in bounds for maze");
	if (!configured) configureGraphics();
	double margin = cellSize*.3;
	double length = cellSize - 2*margin;
	SetPenColor(color);
	MovePen(originX + p.col*cellSize + margin, originY + p.row*cellSize + margin);
	DrawLine(length, length);
	MovePen(originX + p.col*cellSize + margin, originY + p.row*cellSize + cellSize - margin);
	DrawLine(length, -length);
	UpdateDisplay();
}
Пример #10
0
void DrawPrintfMessage(string message)
{
	MovePen( LG , GetWindowHeight()-11.5*LG );
	SetPenColor("White");
	StartFilledRegion(1);
	DrawLine(0,-2*LG);
	DrawLine(23*LG,0);
	DrawLine(0,2*LG);
	DrawLine(-23*LG,0);
	EndFilledRegion();
	SetPenColor("Black");
	MovePen( 2*LG , GetWindowHeight()-12.3*LG );
	DrawTextString(message);
}
Пример #11
0
/* Function: DrawFilledCircleWithLabel
 * Usage:  DrawFilledCircleWithLabel(center, "Green", "You are here");
 * -------------------------------------------------------------------
 * Uses facilities from extgraph to draw a circle filled with
 * color specified. The circle is centered at the given coord has the
 * specified radius.  A label is drawn to the right of the circle.
 * You can leave off the last argument if no label is desired.
 */
void DrawFilledCircleWithLabel(coordT center, string color, string label)
{
	MovePen(center.x + CircleRadius, center.y);
	SetPenColor(color);
	StartFilledRegion(1.0);
	DrawArc(CircleRadius, 0, 360);
	EndFilledRegion();
	if (!label.empty()) {
		MovePen(center.x + CircleRadius, center.y);
		SetFont("Helvetica");
		SetPointSize(LabelFontSize);
		DrawTextString(label);
	}
}
Пример #12
0
/*
 * Function: GetTrianglePoints
 * Usage: GetTrianglePoints(tri)
 * -----------------------------------
 * This function watches the user click three points on the Graphics Console.
 * The function notes the location of those points by loading the 'tri' array
 * with three pointT structs.
 * The function connects the dots to create a triangle on the screen.
 * Graphics should already be initialized.  We assume working with triangles,
 * but the constant nPOINTS will let us see if this works for four points.
 */
void GetTrianglePoints(pointT tri[]) {
    int pt_ct = 0;
    while ( pt_ct < nPOINTS ) {
        //cout << "got to this point" << endl;
        WaitForMouseDown();
        WaitForMouseUp();
        tri[pt_ct].xp = GetMouseX();
        tri[pt_ct].yp = GetMouseY();
        if ( pt_ct == 0 )
        {
            MovePen(tri[0].xp, tri[0].yp);
        }
        else
        {
            DrawLine(
                (tri[pt_ct].xp - tri[pt_ct - 1].xp ),
                (tri[pt_ct].yp - tri[pt_ct - 1].yp )
                    );
        }
        UpdateDisplay();
        pt_ct ++;
    }

    // Connect the third and first points of the triangle with lines
    DrawLine(
        (tri[0].xp - tri[nPOINTS - 1].xp ),
        (tri[0].yp - tri[nPOINTS - 1].yp )
            );
    UpdateDisplay();
}
Пример #13
0
void DrawInnerShade(buttonT & button) {
    MovePen(button.x + 2, button.y + 3);
    DrawLine(button.width - 6, 0);
    DrawLine(0, 1);
    DrawLine(1, 0);
    DrawLine(0, button.height - 6);
}
Пример #14
0
void DrawOuterShade(buttonT & button) {
    MovePen(button.x + 2, button.y + 2);
    DrawLine(button.width - 5, 0);
    DrawLine(0, 1);
    DrawLine(1, 0);
    DrawLine(0, button.height - 5);
}
Пример #15
0
void DrawBox(double x, double y, double width, double height) {
	MovePen(x, y);
	DrawLine(width, 0);
	DrawLine(0, height);
	DrawLine(-width, 0);
	DrawLine(0, -height);
}
Пример #16
0
/*
Function: DrawCircle
Usage: DrawCircle(pt)
-----------------------------------
Given a pointT point (pt), this function draws a circle of radius FILL_RADIUS
and color FILL_COLOR around that point.
 */
void DrawCircle(pointT pt) {
    SetPenColor(FILL_COLOR);
    StartFilledRegion(PT_DENSITY);
    MovePen(pt.xp + FILL_RADIUS, pt.yp);
    DrawArc(FILL_RADIUS, 0, 360);
    EndFilledRegion();
}
Пример #17
0
void createTriangle(Point &v1, Point &v2, Point &v3) {
    int count = 0;
    while(count < 3) {
        WaitForMouseDown();
        WaitForMouseUp();
        double X = GetMouseX();
        double Y = GetMouseY();
        /* log points */
        if (count == 0) {
            MovePen(X, Y);
            v1.X = X;
            v1.Y = Y;
        } else if (count == 1) {
            v2.X = X;
            v2.Y = Y;
            DrawLine(v2.X - v1.X, v2.Y - v1.Y);
        } else {
            v3.X = X;
            v3.Y = Y;
            DrawLine(v3.X - v2.X, v3.Y - v2.Y);
            // close triangle
            DrawLine(v1.X - v3.X, v1.Y - v3.Y);
        }
        count++;
    }
}
Пример #18
0
void clean(int order)
{
	const int sort[3]={2,7,12};
	int i;/*counter*/
	if(order==2)
		for(i=1;i<=4;i++)
		{
			MovePen(click[sort[2]+i].leftup_x,click[sort[2]+i].leftup_y);
			DrawBitmap(click[sort[2]+i].bitmap_B);
		}
	else
		for(i=1;i<=5;i++)
		{
			MovePen(click[sort[order]+i].leftup_x,click[sort[order]+i].leftup_y);
			DrawBitmap(click[sort[order]+i].bitmap_B);
		}
}
Пример #19
0
/* 
 * Function: DrawCenteredChar
 * --------------------------
 * Used to draw the letters in the center of the cube. 
 * Note that this function centers the char
 * both vertically and horizontally around the point specified.
 */ 
static void DrawCenteredChar(double centerX, double centerY, char ch)
{
    string s(1, ch);
    SetFont(CUBE_FONT);
    SetPointSize(gState.cubeFontSize);
    MovePen(centerX - TextStringWidth(s)/2, centerY - GetFontAscent()/2);
    DrawTextString(s);
}
Пример #20
0
void DrawButtonText(buttonT & button) {
    SetFont(BUTTON_FONT);
	SetStyle(BUTTON_STYLE);
    SetPointSize(BUTTON_POINT_SIZE);
    MovePen(button.x + (button.width - TextStringWidth(button.name)) / 2,
            button.y + (button.height + GetFontAscent()) / 2);
    DrawTextString(button.name);
}
Пример #21
0
static void DrawCenteredCircle(double radius, double cx, double cy, string color = "Black", bool isSolid = true) {
	string oldColor = GetPenColor();
	SetPenColor(color);
	MovePen(cx + radius, cy);
	if (isSolid) StartFilledRegion(1.0);
	DrawArc(radius, 0, 360);
	if (isSolid) EndFilledRegion();
	SetPenColor(oldColor);
}
Пример #22
0
static void DrawCenteredText(string text, double cx, double cy, string color) {
	double x = cx - TextStringWidth(text)/2;
	double y = cy - GetFontAscent()/2;
	MovePen(x, y);
	string oldColor = GetPenColor();
	SetPenColor(color);
	DrawTextString(text);
	SetPenColor(oldColor);
}
Пример #23
0
void DrawPathfinderMap(string mapFile) {
	SetPenColor("White");
	FillBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
	SetPenColor("Black");
	if (mapFile != "") {
		MovePen(0, 0);
		DrawNamedPicture(mapFile);
	}
}
Пример #24
0
/* 
 * Function: DrawOneScore
 * ----------------------
 * Draws the specified score for the player according to player enum.
 */
static void DrawOneScore(playerT playerNum, int value)
{   
    SetFont(SCORE_FONT);
    SetPointSize(SCORE_FONT_SIZE);
    SetPenColor("Label Color");
    string str = IntegerToString(value);
    MovePen(gState.scoreBox[playerNum].x + gState.scoreBox[playerNum].w - TextStringWidth(str), 
	    gState.scoreBox[playerNum].y + GetFontDescent() + 0.03); // the 0.03 hack added Sept-2011
    // Using SetEraseMode() to delete old score interfered with the line underneath
    DrawTextString(str);
}
Пример #25
0
void DrawOutline(buttonT & button) {
    MovePen(button.x, button.y + button.height - 2);
    DrawLine(0, 5 - button.height);
    DrawLine(2, -2);
    DrawLine(button.width - 5, 0);
    DrawLine(2, 2);
    DrawLine(0, button.height - 5);
    DrawLine(-2, 2);
    DrawLine(5 - button.width, 0);
    DrawLine(-2, -2);
}
Пример #26
0
static void DrawRoundedRect (double x, double y, double width, double height, double radius)
{
    MovePen(x + radius, y);
    DrawLine(width -2*radius,0);		// line across bottom
    DrawArc(radius,270,90);				// arc on lower right corner
    DrawLine(0,height -2*radius);		// line up right side
    DrawArc(radius,0,90);				// arc on upper right corner
    DrawLine(-(width -2*radius), 0);	// line across top
    DrawArc(radius,90,90);				// arc on upper left corner
    DrawLine(0,-(height-2*radius));		// line down left side
    DrawArc(radius,180,90);				// arc on lower left corner
}
Пример #27
0
void iterate(Point v1, Point v2, Point v3, Point currentPoint) {
	if (MouseButtonIsDown()) ExitGraphics();
	MovePen(currentPoint.X, currentPoint.Y);
	StartFilledRegion(1);
    DrawArc(CIRCLE_SIZE, 0, 360);
    EndFilledRegion();
	Point nextRand = randPoint(v1, v2, v3);
	currentPoint.X = 0.5 * (currentPoint.X + nextRand.X);
	currentPoint.Y = 0.5 * (currentPoint.Y + nextRand.Y);
	UpdateDisplay();
	iterate(v1, v2, v3, currentPoint);
}
Пример #28
0
void MarkHit(coord location,string color,double density)
{
	SetPenColor(color);
	MovePen( (location.col+1.5)*LG,GetWindowHeight()-(location.row+1.3)*LG );
	StartFilledRegion(density);
	DrawLine(-LG/2,-LG/2);
	DrawLine(LG/2,-LG/2);
	DrawLine(LG/2,LG/2);
	DrawLine(-LG/2,LG/2);
	EndFilledRegion();
	SetPenColor("Black");
}
Пример #29
0
void Maze::drawWallsForCell(pointT p)
{
	MovePen(originX + p.col*cellSize, originY + p.row*cellSize);
	SetPenColor(cells(p.row, p.col).walls[South] ? "Black" : "White");
	DrawLine(cellSize, 0);
	SetPenColor(cells(p.row, p.col).walls[East] ? "Black" : "White");
	DrawLine(0, cellSize);
	SetPenColor(cells(p.row, p.col).walls[North] ? "Black" : "White");
	DrawLine(-cellSize, 0);
	SetPenColor(cells(p.row, p.col).walls[West] ? "Black" : "White");
	DrawLine(0, -cellSize);
}
Пример #30
0
void DrawMazeBorder()
{
	double llx = GetMazeLowerLeftX();
	double lly = GetMazeLowerLeftY();

	MovePen(llx, lly);
	DrawLine(0, kMazeDimension, kMazeVisibleColor);
	DrawLine(gWallLength, 0, kMazeInvisibleColor);
	DrawLine(kMazeDimension - gWallLength, 0, kMazeVisibleColor);
	DrawLine(0, -kMazeDimension, kMazeVisibleColor);
	DrawLine(- gWallLength, 0, kMazeInvisibleColor);
	DrawLine(- kMazeDimension + gWallLength, 0, kMazeVisibleColor);
}