Exemplo n.º 1
0
Arquivo: ship.cpp Projeto: npo6ka/OPP
bool Ship::tryAddCell(list <shared_ptr<GameBoardCell>> cells) {
    _bufCells.splice(_bufCells.end(), cells); //совмещаем листы
    if (_bufCells.size() >= 0 && _bufCells.size() <= (unsigned int)getSize()) { //сумма ячеек не должна превышать размер карабля
        if (_bufCells.size() == 1) return 1; //если однопалубник, всё проще
        if (resetDir() == UNK) return 0; //просчитываем новое направление карабля 
        sortCell();
        return checkShip();
    } else return 0;
}
Exemplo n.º 2
0
EventManager::EventManager(QWidget &parent, GameManager &engine, uint speed) :
  QWidget(&parent, 0),
  _snake(engine.getSnake()),
  _land(engine.getLand()),
  _engine(engine)
{
  setFocusPolicy(Qt::StrongFocus);
  connect(&_timer, SIGNAL(timeout()), this, SLOT(moveSnake()));
  _timer.start(100 / speed);
  resetDir();
  _left = false;
}