MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), end(0), start(0,0), cel(0,0), ui(new Ui::MainWindow) { QString nazwa; ui->setupUi(this); this->setGeometry(0,0,1300,700); pole = new QPushButton**[8]; for (int i=0;i<8;i++) { pole[i] = new QPushButton*[8]; for (int j=0;j<8;j++) { pole[i][j] = new QPushButton(this); pole[i][j]->setGeometry(15+pole_wymiar*i,pole_wymiar*7+15-pole_wymiar*j,pole_wymiar,pole_wymiar); pole[i][j]->setIconSize(QSize(pole_wymiar,pole_wymiar)); nazwa=(i+65); nazwa+=(j+49); pole[i][j]->setObjectName(nazwa); connect(pole[i][j],SIGNAL(clicked()),this,SLOT(qruch())); } } awans = new QPushButton(this); awans->setGeometry(100+8*pole_wymiar,15+4*pole_wymiar,pole_wymiar,pole_wymiar); awans->setIconSize((QSize(pole_wymiar,pole_wymiar))); connect(awans,SIGNAL(clicked()),this,SLOT(tawans())); log = new QTextBrowser(this); log->setGeometry(100+8*pole_wymiar,15,300,300); log->setStyleSheet("background-color: white; border: 3px solid grey"); log->isReadOnly(); szachownica(); tawans(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glFrontFace(GL_CW); glUseProgram(shader); M3DVector3f at={0.0f, 0.0f, 0.0f}; M3DVector3f up={0.0f, 0.0f, 1.0f}; M3DVector3f eye; float angle = timer.GetElapsedSeconds()*3.14159f/8; eye[0]= 6.8f * cos(angle); eye[1]= 6.0f * sin(angle); eye[2]= 25.0f; LookAt(cameraFrame,eye,at,up); projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); szachownica(); modelView.Translate(0.0f, 0.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(5.0f, 0.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-5.0f, 0.0f, 0.0f); modelView.Scale(2.0f, 2.0f, 2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
int main(){ szachownica(); return 0; }
/*! * * \brief Definicja funkcji reprezentująca wykonywane ruchy przez figury. */ void MainWindow::qruch() { Pole tmp(sender()->objectName().toStdString()); if (!end) { if (start == Pole(0,0)) { if (R.P[tmp.x()][tmp.y()].figtype()!=0) { if (R.P[tmp.x()][tmp.y()].kolor() == R.next) { start = tmp; qmozliwe = R.ruchy(R.P[tmp.x()][tmp.y()]); szachownica(qmozliwe); } } } else { for (unsigned int i=0;i<qmozliwe.size();i++) { if (tmp == qmozliwe[i]) { cel = tmp; break; } } if (cel != Pole(0,0)) { R.ruch(start,cel); R.bulid_one(); if (R.wsk.empty()) { if (R.next) { if(R.szach(R.bking)) { R.addlog(start,cel); R.addlog("biale mat"); } else { R.addlog(start,cel); R.addlog("pat"); } } else { if(R.szach(R.wking)) { R.addlog(start,cel); R.addlog("czarne mat"); } else { R.addlog(start,cel); R.addlog("pat"); } } displog(); display(); start=Pole(0,0); cel=Pole(0,0); qmozliwe.clear(); szachownica(); return; } R.addlog(start,cel); displog(); display(); R.bulid_tree(); R.minmax(); Pole s=R.wyb->st; Pole c=R.wyb->cl; R.ruch(s,c); R.bulid_one(); if (R.wsk.empty()) { if (R.next) { if(R.szach(R.bking)) { R.addlog(start,cel); R.addlog("biale mat"); } else { R.addlog(start,cel); R.addlog("pat"); } } else { if(R.szach(R.wking)) { R.addlog(start,cel); R.addlog("czarne mat"); } else { R.addlog(start,cel); R.addlog("pat"); } } displog(); display(); start=Pole(0,0); cel=Pole(0,0); qmozliwe.clear(); szachownica(); return; } R.addlog(s,c); displog(); display(); } start=Pole(0,0); cel=Pole(0,0); qmozliwe.clear(); szachownica(); R.Biale.clear(); R.Czarne.clear(); R.wsk.clear(); } } }