예제 #1
0
    int main(int argc, char **argv){

        glutInit(&argc,argv);
        glutInitWindowPosition(-1,-1); 
        glutInitWindowSize(screen_width,screen_height);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
        glutInitContextVersion(2, 1);
        glutCreateWindow("Fischer Random Chess");

        glewExperimental = GL_TRUE;
        glewInit();
        initGL();
        initDLs();
        loadPieces();
        gamestate = WHITE_TURN; 

        glClearColor(0.8, 0.8, 0.8, 1);
        glutDisplayFunc(draw);
        glutIdleFunc(draw);
        glutReshapeFunc(resize);
        glutKeyboardFunc(keyEvents);
        glutSpecialFunc(specialKeys);
        glutMouseFunc(mouse);

        glutMainLoop();

        return 1;
    }
예제 #2
0
void BoardTheme::configure()
{
    AppSettings->beginGroup("/Board/");
    setColor(BoardTheme::LightSquare, AppSettings->getValue("lightColor").value<QColor>());
    setColor(BoardTheme::DarkSquare, AppSettings->getValue("darkColor").value<QColor>());
    setColor(BoardTheme::Highlight, AppSettings->getValue("highlightColor").value<QColor>());
    setColor(BoardTheme::Frame, AppSettings->getValue("frameColor").value<QColor>());
    setColor(BoardTheme::CurrentMove, AppSettings->getValue("currentMoveColor").value<QColor>());
    setColor(BoardTheme::StoredMove, AppSettings->getValue("storedMoveColor").value<QColor>());
    setColor(BoardTheme::Threat, AppSettings->getValue("threatColor").value<QColor>());
    setColor(BoardTheme::Target, AppSettings->getValue("targetColor").value<QColor>());
    setColor(BoardTheme::Check, AppSettings->getValue("checkColor").value<QColor>());
    setColor(BoardTheme::Wall, AppSettings->getValue("wallColor").value<QColor>());
    setColor(BoardTheme::UnderProtected, AppSettings->getValue("underprotectedColor").value<QColor>());

    QString pieceTheme = AppSettings->getValue("pieceTheme").toString();
    int pieceEffect = AppSettings->getValue("pieceEffect").toInt();
    QString boardTheme = AppSettings->getValue("boardTheme").toString();
    AppSettings->endGroup();

    if(!loadPieces(pieceTheme, pieceEffect))
    {
        static bool errorShown = false;
        if (!errorShown)
        {
            errorShown = true;
            MessageDialog::error(tr("Cannot find piece data.\nPlease check your installation."));
        }
    }
    if (!loadBoard(boardTheme))
    {
        static bool errorShown = false;
        if (!errorShown)
        {
            errorShown = true;
            MessageDialog::error(tr("Cannot find board data.\nPlease check your installation."));
        }
    }
}
예제 #3
0
void keyEvents(unsigned char key, int x, int y){
    switch(key){
        case 27: 
        glDetachShader(p,v);
        glDetachShader(p,f);
        glDeleteShader(v);
        glDeleteShader(f);
        glDeleteProgram(p);
        for(int i = 0; i < pieces.size(); i++){
            free(pieces.at(i));
        }
        printf("shaders freed\n");
        exit(0);
        break;
    }
    if (key == '1') { 

        pieces.clear();        
        side_pieces.clear();

        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
                grid_pieces[i][j] = 0;
            }
        }

        clearMovesList();
        loadPieces();
        gamestate = WHITE_TURN;
    }  
    if (key == '2') { 

        pieces.clear();        
        side_pieces.clear();
        
        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
                grid_pieces[i][j] = 0;
            }
        }

        clearMovesList();
        loadPiecesRandom();
        gamestate = WHITE_TURN;
    } 
    if (key == '3') { 

        pieces.clear();        
        side_pieces.clear();
        
        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
                grid_pieces[i][j] = 0;
            }
        }

        clearMovesList();
        loadPiecesDoubleRandom();
        gamestate = WHITE_TURN;
    } 

    
}