示例#1
0
void WarpTile::reopen() {
    holePixmap.setVisible(true);
    holeOpen = true;
    if(position().x() < MAPW/2) {
        MapTile *mt = playfield->tileAt(position() + QPoint(1,0));
        if(mt->walls() & MT_W) mt->setWalls(mt->walls() - MT_W);
    } else {
        if(walls() & MT_W) setWalls(walls() - MT_W);
    }
}
示例#2
0
void Window::startNewGame() {
    setWalls();
    this->helper.b->initialize();
    //setWalls();
    this->openGL->repaint();
    updateText();
    this->stepButton->setEnabled(true);
    this->playButton->setEnabled(true);
    this->pauseButton->setEnabled(true);
    this->captureTargetSpinBox->setEnabled(true);
    this->maxRoundsSpinBox->setEnabled(true);
}
示例#3
0
QPointF WarpTile::warpTo() {
    if(!holeOpen)
        return pos();
    Q_ASSERT(targetTile);
    holePixmap.setVisible(false);
    holeOpen = false;
    closedTimer.start(5000);
    targetTile->warpTo();
    if(position().x() < MAPW/2) {
        MapTile *mt = playfield->tileAt(position() + QPoint(1,0));
        mt->setWalls(mt->walls() | MT_W);
    } else {
        setWalls(walls() | MT_W);
    }
    return targetTile->pos();
}
示例#4
0
Window::Window()
{
    this->timerDelay = 250;
    setWalls();
    this->helper.b->initialize();
    //setWalls();
    setWindowTitle(QString("Mosquito Buzz Buzz: " + this->helper.b->player->playerName));

    this->openGL = new GLWidget(&this->helper, this);

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(openGL, 0, 1);
    //layout->addWidget(openGLLabel, 1, 1);
    setLayout(layout);

    this->mosquitoLabel = new QLabel(this);
    layout->addWidget(this->mosquitoLabel, 1, 1);
    mosquitoLabel->setText("Mosquitoes Eaten: 0");
    mosquitoLabel->setAlignment(Qt::AlignLeft);

    this->roundLabel = new QLabel(this);
    layout->addWidget(this->roundLabel, 1, 1);
    roundLabel->setText("Round: 0");
    roundLabel->setAlignment(Qt::AlignHCenter);

    this->timer = new QTimer(this);
    connect(this->timer, SIGNAL(timeout()), openGL, SLOT(animate()));
    connect(this->timer, SIGNAL (timeout()), this, SLOT(updateText()));
    this->timer->start(this->timerDelay);

    this->stepButton = new QPushButton("Step", this);
    layout->addWidget(stepButton, 3, 1);
    layout->setAlignment(stepButton, Qt::AlignTop);
    connect(stepButton, SIGNAL (released()), openGL, SLOT (step()));
    connect(stepButton, SIGNAL (released()), this, SLOT(updateText()));

    this->playButton = new QPushButton("Play", this);
    this->playButton->setMinimumWidth(250);
    layout->addWidget(playButton, 4, 1);
    layout->setAlignment(playButton, Qt::AlignLeft);
    connect(playButton, SIGNAL (released()), openGL, SLOT (play()));
    connect(playButton, SIGNAL (released()), this, SLOT(play()));

    this->pauseButton = new QPushButton("Pause", this);
    this->pauseButton->setMinimumWidth(250);
    layout->addWidget(pauseButton, 4, 1);
    layout->setAlignment(pauseButton, Qt::AlignRight);
    connect(pauseButton, SIGNAL (released()), this, SLOT (stop()));
    connect(pauseButton, SIGNAL (released()), openGL, SLOT (stop()));

    this->newGameButton = new QPushButton("Begin New Game", this);
    layout->addWidget(newGameButton, 1, 1);
    layout->setAlignment(newGameButton, Qt::AlignRight);
    connect(newGameButton, SIGNAL (released()), this, SLOT(startNewGame()));

    this->timeDelaySlider = new QSlider(Qt::Horizontal, this);
    this->timeDelaySlider->setFixedWidth(400);
    this->timeDelaySlider->setMinimum(0);
    this->timeDelaySlider->setSingleStep(10);
    this->timeDelaySlider->setValue(250);
    this->timeDelaySlider->setMaximum(800);
    this->timeDelaySlider->setSingleStep(10);
    connect(this->timeDelaySlider, SIGNAL (sliderReleased()), this, SLOT(changeTimerDelay()));
    layout->addWidget(this->timeDelaySlider, 5, 1);
    layout->setAlignment(this->timeDelaySlider, Qt::AlignRight);

    QLabel* timerLabel = new QLabel(this);
    layout->addWidget(timerLabel, 5, 1);
    layout->setAlignment(timerLabel, Qt::AlignLeft);
    timerLabel->setText("Timer Delay");
    timerLabel->setIndent(10);
    timerLabel->setBuddy(this->timeDelaySlider);

    QLabel* captureTargetLabel = new QLabel(this);
    layout->addWidget(captureTargetLabel, 2, 1);
    captureTargetLabel->setIndent(65);
    captureTargetLabel->setText("Capture Target (%)");

    this->captureTargetSpinBox = new QSpinBox; // set percentage for capture rate needed to win
    captureTargetSpinBox->setRange(1, 100);
    captureTargetSpinBox->setValue(100);
    layout->addWidget(captureTargetSpinBox, 2, 1);
    layout->setAlignment(captureTargetSpinBox, Qt::AlignLeft);
    connect(captureTargetSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateCaptureTarget()));

    QLabel* roundsLabel = new QLabel(this);
    layout->addWidget(roundsLabel, 2, 1);
    layout->setAlignment(roundsLabel, Qt::AlignCenter);
    roundsLabel->setIndent(170);
    roundsLabel->setText("Rounds (max)");

    this->maxRoundsSpinBox = new QSpinBox; // set max num of rounds before game over
    maxRoundsSpinBox->setRange(100, 10000);
    maxRoundsSpinBox->setValue(5000);
    layout->addWidget(maxRoundsSpinBox, 2, 1);
    layout->setAlignment(maxRoundsSpinBox, Qt::AlignCenter);
    connect(maxRoundsSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateMaxRounds()));
}