void Game::mousePressEvent(QMouseEvent *pe){ if(pe->buttons() == 1){ int x = pe->x()/50; int y = (500-pe->y())/50; if(arrayofpoints[x][y] != NULL){ if(activepoint != NULL) activepoint->active = 0; activepoint=arrayofpoints[x][y]; activepoint->active = 1; } else { if(activepoint != NULL){ ///////////////////////////////////////// if(movepoint(activepoint->x/50,activepoint->y/50,x,y)){ if(!checkarray()){ emit scoreChanged(); addpoint(); addpoint(); addpoint(); } checkarray(); emit scoreChanged(); } ///////////////////////////////////////// } } } if(pe->buttons() == 2){ if(activepoint){ activepoint->active = 0; activepoint = NULL; } } }
void movepoly(struct poly* p) //移动单个多边形,内部调用点的移动 { int i; for (i=0; i<p->n_point; ++i) { movepoint(&(p->p[i])); } }