void Connector::setup(QLabel *ql, QLineEdit *le, QPushButton *mBtn, QPushButton *dBtn, Canvas *c) { status = ql; ipBox = le; modeBtn = mBtn; delayBtn = dBtn; canvas = c; connect(this, SIGNAL(addY()), canvas, SLOT(addY())); connect(this, SIGNAL(subY()), canvas, SLOT(subY())); connect(this, SIGNAL(addX()), canvas, SLOT(addX())); connect(this, SIGNAL(subX()), canvas, SLOT(subX())); connect(this, SIGNAL(paint()), canvas, SLOT(paintClicked())); }
int main(void){ int row,col,testPoint=1,diceCount; int i; while(scanf("%d%d",&width,&height) != EOF){ diceCount = 0; Xcount = 0; if(width == 0)break; scanf(" "); for(row = 1;row <= height; row++){ for(col = 1; col <= width; col++){ field[col][row] = getchar(); visit[col][row] = 0; check[col][row] = 0; if(field[col][row] == 'X') addX(col,row); } scanf(" "); } delX(); for(i = 0; i < Xcount; i++) if(!check[(Xdata+i) -> x][(Xdata+i) -> y]) dice[diceCount++] = dfs((Xdata+i) -> x,(Xdata+i) -> y); qsort(dice,diceCount,sizeof(int),compareInt); printf("Throw %d\n",testPoint++); for(i = 0; i < diceCount - 1;i++) printf("%d ",dice[i]); printf("%d\n\n",dice[diceCount-1]); } return 0; }
void Connector::timesUp() { QPair<int, int> next = cmdQ.dequeue(); switch(next.first) { case CW: axis_number = next.second; canvas->rotateCW(); break; case CCW: axis_number = next.second; canvas->rotateCCW(); break; case ADDY: emit addY(); break; case SUBY: emit subY(); break; case ADDX: emit addX(); break; case SUBX: emit subX(); break; case PAINT: emit paint(); break; default: qDebug() << "RECEIVE ERROR:" << next.first; break; } }
void RectangleSDL::move(Box2D *limit) { colliding = false; if ( hor ) { if ( getRightSide() + speed >= limit->getRightSide() ) { hor = false; colliding = true; } else { addX(speed); } } else { if ( getLeftSide() - speed <= limit->getLeftSide() ) { hor = true; colliding = true; } else { addX(-speed); } } if ( vert ) { if ( getBottomSide() + speed >= limit->getBottomSide() ) { vert = false; colliding = true; } else { addY(speed); } } else { if ( getTopSide() - speed <= limit->getTopSide() ) { vert = true; colliding = true; } else { addY(-speed); } } }
void Connector::readCommands() { if (client) { qDebug() << "READ - NOT SERVER"; return; } char buf[2] = {0}; serverSock->read(buf, serverSock->bytesAvailable()); int command = int(buf[0]); int axis = int(buf[1]); if (delay) { cmdQ.enqueue(qMakePair(command, axis)); QTimer::singleShot(2000, this, SLOT(timesUp())); } else { switch(command) { case CW: axis_number = next.second; canvas->rotateCW(); break; case CCW: axis_number = next.second; canvas->rotateCCW(); break; case ADDY: emit addY(); break; case SUBY: emit subY(); break; case ADDX: emit addX(); break; case SUBX: emit subX(); break; case PAINT: emit paint(); break; default: qDebug() << "RECEIVE ERROR:" << next.first; break; } } }
void FlyingEnemy::update() { if(!dead) { buddy->move(getX() - level->getXOffs(), getY() - level->getYOffs()); if(dir == -1) { //If going left if(level->testCollision(getX() - 1, getY())) { dir = 1; } } else if(dir == 1) { //If going right if(level->testCollision(getX() + Entity::SIZE + 1, getY())) { dir = -1; } } addX(hSpeed * dir); Player* p = level->getPlayer(); if(isCollidingWith(p)) { QRect test(getX(), getY(), getWidth(), 32); if(p->isInvincible() || test.contains(p->getX(), p->getY() + p->getHeight()) || test.contains(p->getX() + p->getWidth(), p->getY() + p->getHeight())) { Network::instance().send("Enemy " + QString::number(id)); dead = true; p->setVib(true); } else { p->setDead(true); } } if(dir == 1) { buddy->setPixmap(feRight); } else if(dir == -1) { buddy->setPixmap(feLeft); } } else { if(curHeight > 8) { curHeight -= 8; buddy->setGeometry(getX() + (Entity::SIZE / 2 - curHeight / 2) - level->getXOffs(), getY() + (Entity::SIZE / 2 - curHeight / 2) - level->getYOffs(), curHeight, curHeight); } else { Sound::instance().killedEnemy(); buddy->deleteLater(); level->removeEntity(this); } } }
bool Fly::slide(sf::Sprite & sprt){ float tmpangle = tz.intersectAngle(sprt); if(tmpangle == -100) return true; if(tmpangle > PI) tmpangle -= 2.*PI; if(tmpangle < -PI) tmpangle += 2.*PI; float comparAngle = angle - tmpangle; if(comparAngle > PI) comparAngle -= 2.*PI; if(comparAngle < -PI) comparAngle += 2.*PI; //TODO : revoir cette partie**** if(comparAngle < PI/6. && comparAngle > -PI/6.) return true; //****************************** if(comparAngle < 0 ) angle = tmpangle - PI/2.; else if (comparAngle > 0 ) angle = tmpangle + PI/2.; else return true; addX(-cos(tmpangle)*vitesse); addY(-sin(tmpangle)*vitesse); dX = cos(angle); dY = sin(angle); return false; }
// Provided thread code void producer(int thread_id) { // The declaration of j as an integer was added on 10/24/2011 // The threads with ID#(0 - 3) perform insertion/deletion operations for 10 times // while other threads perform the operations for 15 times int i, j, n; n = (thread_id < 4)? 10: 15; for (i = 0; i < n; i++) { // Wait on empty mysem_wait(empty); // Wait on mutex mysem_wait(mutex); // modify the buffer addX(); // Release stuff, up full mysem_signal(mutex); mysem_signal(full); for (j = 0; j < MAX; j++); } }
void Fly::move(){ QPoint tmp(x,y); if(angle > PI){ angle -= 2.*PI; } else if (angle < -PI){ angle += 2.*PI; } if(!stop){ chFrame(); if(isControl) controledMove(); else defaultMove(); addX(dX*vitesse); addY(dY*vitesse); if(positions.size() < 20) positions.append(tmp); else{ QPoint tmp2; int d = positions.size() -1; for(int i = d; i > 0;i-=2){ tmp2 = positions[i]; positions.replace(i,tmp); tmp = positions[i-1]; positions.replace(i-1,tmp2); } } } }
int Entite::move(){ addX(speedVector.first); addY(speedVector.second); return 0; }
/// /// 加算 void add(Vec3& rhs) { addX(rhs.x_); addY(rhs.y_); addZ(rhs.z_); }
void Fly::wall(){ vitesse = standardVelo; addX(-dX*vitesse); addY(-dY*vitesse); }
void Point::move(Point* other) { addX(other->getX()); addY(other->getY()); addZ(other->getZ()); }