Ejemplo n.º 1
0
void DrawPuzzlePieces() {
    glClear(GL_COLOR_BUFFER_BIT);
    
    for (int i = 0; i < PIECES_SIZE; i++) {
        if (i != holdingPiece) {
            glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
            // Fix out of bounds
            if (pieces[i].x_Location + pieces[i].size > glutGet(GLUT_WINDOW_WIDTH)) {
                pieces[i].x_Location = glutGet(GLUT_WINDOW_WIDTH) - pieces[i].size;
            }
            else if (pieces[i].x_Location < 0) {
                pieces[i].x_Location = 0;
            }
            if (pieces[i].y_Location + pieces[i].size > glutGet(GLUT_WINDOW_HEIGHT)) {
                pieces[i].y_Location = glutGet(GLUT_WINDOW_HEIGHT) - pieces[i].size;
            }
            else if (pieces[i].y_Location < 0) {
                pieces[i].y_Location = 0;
            }
            DrawPiece(pieces[i]);
            DrawLetter(pieces[i]);
        }
    }
    if (holdingPiece >= 0) {
        glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        DrawPiece(pieces[holdingPiece]);
        DrawLetter(pieces[holdingPiece]);
        glDisable(GL_BLEND);
    }
    
    glFlush();
}
Ejemplo n.º 2
0
static void init_rs_cb(GtkWidget *widget,
                       gpointer   data)
{
    InitializeGame();
    int x = 0;
    int y = 0;
    NodeType t;
    for (int i = 0; i <= 2; ++i) {
        t = (i == 1) ? Black : White;
        x = (BoardSize - 9) / 2 + rand() % 9;
        y = (BoardSize - 9) / 2 + rand() % 9;
        if (game.board[x][y] == Empty) {
            game.board[x][y] = t;
            DrawPiece(x, y, t);
        }
    }

    if (game.blackAI.id != 10) {
        Point p;
        p = game.blackAI.func(game.board, Black);
        game.Move(p);
        DrawPiece(p.x, p.y, Black);
    }
    GtkWidget* draw_area = (GtkWidget*) data;
    gtk_widget_queue_draw_area(draw_area, 0, 0, CanvasWidth, CanvasWidth);

}
Ejemplo n.º 3
0
static void PutPiece(GtkWidget *widget, 
                     GdkEventMotion *event, 
                     gpointer   data)
{
    if (game.winner == Empty && game.isBlackPlaying == (game.blackAI.id == 10)) {
        Point p(GetRowColFromPixel(event->x), GetRowColFromPixel(event->y));
        if (game.Move(p) == true) {
            DrawPiece(GetRowColFromPixel(event->x), GetRowColFromPixel(event->y), 
                    game.isBlackPlaying ? White : Black);
            gtk_widget_queue_draw_area(widget, 0, 0, CanvasWidth, CanvasWidth);
            if (game.CheckVictory() != Empty) {
                return;
            } else {
                if (game.isBlackPlaying) {
                    p = game.blackAI.func(game.board, Black);
                    game.Move(p);
                    DrawPiece(p.x, p.y, Black);
                } else {
                    p = game.whiteAI.func(game.board, White);
                    game.Move(p);
                    DrawPiece(p.x, p.y, White);
                }
                if (game.CheckVictory() != Empty)
                    return;
            }
        }
    }
}
Ejemplo n.º 4
0
void CPuzzle::OnDraw(HDC hDC, LPRECT lpRect, BOOL fGrid)
/***********************************************************************/
{
	int iPieces;
	RECT rOut, rClient, rPaint, rWindow;
	HDC hDCOut;
	POINT ptDst;
	PDIB pDibOut = NULL;

	GetClientRect(m_hWnd, &rClient);
	GetWindowRect(m_hWnd, &rWindow);
	if (!IntersectRect(&rPaint, &rClient, lpRect))
		return;
	if (!m_pDib)
		return;

	LPSCENE lpScene = CScene::GetScene(GetParent(m_hWnd));
	if (!lpScene)
		return;
	LPOFFSCREEN lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		hDCOut = lpOffScreen->GetDC();
		rOut = rPaint;
		MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rOut, 2 );
		MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rClient, 2 );
		MapWindowPoints( NULL, GetParent(m_hWnd), (LPPOINT)&rWindow, 2 );
		pDibOut = lpOffScreen->GetWritableDIB();
	}
	else
		hDCOut = hDC;

	iPieces = m_iCols * m_iRows;
	for (int i = 0; i < iPieces; ++i)
		DrawPiece(i, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, fGrid);

	if (m_iSelect >= 0)
	{
		if (m_bHintMode)
			DrawHint(m_iSelect, hDCOut, (LPPOINT)&rClient.left, &rPaint);
		DrawPiece(m_iSelect, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, FALSE, &m_ptSelect);
	}

	// when we are all done we draw from the WinG DC to the output DC
	if (lpOffScreen)
	{
		ptDst.x = rPaint.left;
		ptDst.y = rPaint.top;
		lpOffScreen->DrawRect( hDC, &rOut, &ptDst );
	}
}
Ejemplo n.º 5
0
void Game::DrawGrid( int x, int y )
{
	//Vertical lines
	gfx.DrawLine( x, y, x, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 114, y, x + 114, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 228, y, x + 228, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 342, y, x + 342, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 456, y, x + 456, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 570, y, x + 570, y + 500, 255, 255, 255 );
	gfx.DrawLine( x + 684, y, x + 684, y + 500, 255, 255, 255 );

	//Horizontal Lines
	gfx.DrawLine( 0, y, x + 684, y, 255, 255, 255 );
	gfx.DrawLine( 0, y + 83, x + 684, y + 83, 255, 255, 255 );
	gfx.DrawLine( 0, y + 166, x + 684, y + 166, 255, 255, 255 );
	gfx.DrawLine( 0, y + 249, x + 684, y + 249, 255, 255, 255 );
	gfx.DrawLine( 0, y + 332, x + 684, y + 332, 255, 255, 255 );
	gfx.DrawLine( 0, y + 415, x + 684, y + 415, 255, 255, 255 );

	for( int r = 0; r < 6; r++ ){
		for( int c = 0; c < 7; c++ ){
			DrawPiece( c * 114, r * 83 + 90, grid[r][c] );	//Rows and columns are backwards here because arrays in
															//C++ goes [r, c](y, x) instead of [c, r](x, y)
		}
	}
}
Ejemplo n.º 6
0
void ClipBitmapStyleEditor::Draw(wxDC& dc)
{
	if (!m_pClipBitmapStyle) return;

	const PieceInfo* pDefaultPieceInfo = m_pClipBitmapStyle->GetStatePiece(IStyle::SS_NORMAL);

	for (int i = 0; i < IStyle::SS_NUM; ++i)
	{
		const PieceInfo* pPieceInfo = pDefaultPieceInfo;
		const PieceInfo* pCurrPieceInfo = m_pClipBitmapStyle->GetStatePiece((IStyle::STYLE_STATE)i);
		if (pCurrPieceInfo) pPieceInfo = pCurrPieceInfo;

		if (!pPieceInfo)
		{
			dc.SetPen(wxPen(*wxLIGHT_GREY, Config::DISABLED_PEN_WIDTH));
			dc.SetBrush(*wxGREY_BRUSH);
			DrawRectangle(dc, m_rectState[i]);
			DrawLine(dc, wxPoint(m_rectState[i].x, m_rectState[i].y), wxPoint(m_rectState[i].x+m_rectState[i].width, m_rectState[i].y+m_rectState[i].height));
			DrawLine(dc, wxPoint(m_rectState[i].x, m_rectState[i].y+m_rectState[i].height), wxPoint(m_rectState[i].x+m_rectState[i].width, m_rectState[i].y));
		}
		else
		{
			DrawPiece(dc, m_rectState[i].GetPosition(), pPieceInfo);
		}
	}

	DrawSelection(dc);
}
Ejemplo n.º 7
0
void Game::DrawCursor( int x, int y )
{
	gfx.DrawLine( x + 8, y + 8, x + 48, y + 8, 0, 255, 0 );
	gfx.DrawLine( x + 8, y + 9, x + 8, y + 48, 0, 255, 0 );
	gfx.DrawLine( x + 91, y + 91, x + 51, y + 91, 0, 255, 0 );
	gfx.DrawLine( x + 91, y + 91, x + 91, y + 51, 0, 255, 0 );
	
	DrawPiece( cursorX, cursorY, playerState );
}
Ejemplo n.º 8
0
// draw 3D
void Tetris::Draw(game_info* gi)
{
	if (!engine.network_thread && gi->side == 1)
	{
		return;
	}

	DrawBoard(gi);

	DrawPiece(gi, (0.5) * (double)gi->pos, gi->fine);
}
Ejemplo n.º 9
0
static void init_cb(GtkWidget *widget,
                    gpointer   data)
{
    InitializeGame();
    if (game.blackAI.id != 10) {
        Point p;
        p = game.blackAI.func(game.board, Black);
        game.Move(p);
        DrawPiece(p.x, p.y, Black);
    }
    GtkWidget* draw_area = (GtkWidget*) data;
    gtk_widget_queue_draw_area(draw_area, 0, 0, CanvasWidth, CanvasWidth);
}
Ejemplo n.º 10
0
void CChessGUI::DrawPieces()
{
	glColor3f(0, 200, 0);
	for(int i = 0; i < 16; i++)
	{
		if(theGame->player1->pieces[i]->isAlive() == true)
		{
			DrawPiece(*theGame->player1->pieces[i]);
		}
	}

	glColor3f(0, 10, 200);
	for(int i = 0; i < 16; i++)
	{
		if(theGame->player2->pieces[i]->isAlive() == true)
		{
			DrawPiece(*theGame->player2->pieces[i]);
		}
	}

	glColor3f(0, 0, 0);
}
Ejemplo n.º 11
0
/* 
======================================									
Draw scene

Draw all the objects of the scene
====================================== 
*/
void Game::DrawScene ()
{
	DrawBoard ();													// Draw the delimitation lines and blocks stored in the board
	DrawPiece (mPosX, mPosY, mPiece, mRotation);					// Draw the playing piece
	DrawPiece (mNextPosX, mNextPosY, mNextPiece, mNextRotation);	// Draw the next piece
}
Ejemplo n.º 12
0
void pawsFrameDrawable::Draw(int x, int y, int newWidth, int newHeight, int alpha)
{
    if (alpha < 0)
        alpha = defaultAlphaValue;

    int w1, w2;
    switch (type)
    {
    // NOTE: For these tiled backgrounds, the border images are OUTSIDE of the
    //       x,y,newWidth,newHeight rectangle, so cursors and text are
    //       placed properly.

    case FDT_HORIZONTAL:
        w1 = pieces[FDP_LEFT].drawable->GetWidth();
        w2 = pieces[FDP_RIGHT].drawable->GetWidth();
        DrawPiece(FDP_LEFT, x-w1, y, w1, newHeight, alpha, false, false);
        DrawPiece(FDP_RIGHT, x+newWidth, y, w2, newHeight, alpha, false, false);
        DrawPiece(FDP_MIDDLE, x, y, newWidth, newHeight, alpha, true, false);
        break;
    case FDT_VERTICAL:
        w1 = pieces[FDP_TOP].drawable->GetHeight();
        w2 = pieces[FDP_BOTTOM].drawable->GetHeight();
        DrawPiece(FDP_TOP, x, y-w1, newWidth, w1, alpha);
        DrawPiece(FDP_BOTTOM, x, y+newHeight, newWidth, w2, alpha);
        DrawPiece(FDP_MIDDLE, x, y, newWidth, newHeight, alpha);
        break;
    case FDT_FULL:
    {
        int midLeft   = x;
        int midTop    = y ;
        int midRight  = x + newWidth;
        int midBottom = y + newHeight;

        DrawPiece(FDP_TOP_LEFT, x - pieces[FDP_TOP_LEFT].drawable->GetWidth(), y - pieces[FDP_TOP_LEFT].drawable->GetHeight(), alpha);
        DrawPiece(FDP_TOP, midLeft, midTop-pieces[FDP_TOP].drawable->GetHeight(), midRight-midLeft, pieces[FDP_TOP].drawable->GetHeight(), alpha, true, false);
        DrawPiece(FDP_TOP_RIGHT, midRight, y - pieces[FDP_TOP_RIGHT].drawable->GetHeight(), alpha);

        DrawPiece(FDP_LEFT, midLeft-pieces[FDP_LEFT].drawable->GetWidth(), midTop, pieces[FDP_LEFT].drawable->GetWidth(), midBottom-midTop, alpha, false, true);
        DrawPiece(FDP_MIDDLE, midLeft, midTop, midRight-midLeft, midBottom-midTop, alpha, true, true);
        DrawPiece(FDP_RIGHT, midRight, midTop, pieces[FDP_RIGHT].drawable->GetWidth(), midBottom-midTop, alpha, false, true);

        DrawPiece(FDP_BOTTOM_LEFT, midLeft-pieces[FDP_BOTTOM_LEFT].drawable->GetWidth(), midBottom, alpha);
        DrawPiece(FDP_BOTTOM, midLeft, midBottom, midRight-midLeft, pieces[FDP_BOTTOM].drawable->GetHeight(), alpha, true, false);
        DrawPiece(FDP_BOTTOM_RIGHT, midRight, midBottom, alpha);
        break;
    }
    case FDT_COUNT:
        break;
    }
}
Ejemplo n.º 13
0
void Game::DrawGameOver()
{
	DrawBoard();																			// Draw the delimitation lines and blocks stored in the board
	DrawPiece( m_nextPosX, m_nextPosY, m_nextFigure, m_nextRotation, m_nextColor, true );	// Draw the next piece
}
Ejemplo n.º 14
0
void Game::DrawScene()
{
	DrawBoard();																			// Draw the delimitation lines and blocks stored in the board
	DrawPiece( m_posX, m_posY, m_figure, m_rotation, m_color );								// Draw the playing piece
	DrawPiece( m_nextPosX, m_nextPosY, m_nextFigure, m_nextRotation, m_nextColor, true );	// Draw the next piece
}