/*reads in the map (array), the start locations (a,b), and the end locations (c,d)
1 looks to see if it has made it to the start or the end
2 makes current location a x 
3 it looks for a bread crumb or a wall on the right and if there is a opening straight
4 if not it will see it there is only a wall to the right if so it turns left
5 if there is not a wall it will turn right
no return
*/
void traverse (char array[200][200],int a,int b,int c,int d, char dir){
	//declorations
	int myX=a;														// seting the man to the start
	int myY=b;
	
	//end declorations
	
	while (1){
		printf("x,%d, y,%d dir %c \n",myX, myY, dir);                           // test location
		//fgetc(stdin);
		//printMaze(array,100,100);
		if ( myX==c && myY==d){
			array [myX][myY]='x';
			printf("you got out");
			break;
		}
		if ( myX==a && myY==b && array [myX][myY]=='x'){
			printf("no way out");
			break;
		}
		array [myX][myY]='x';
		if (array[myX-1][myY]=='x'&& array[myX+1][myY]=='x'&& array[myX][myY-1]=='x' && array[myX][myY+1]=='x'){
			dir = turnRight (dir);
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location
		}else if (openStright(array,myX,myY,dir) && openRight(array,myX,myY,dir)){
			dir = turnRight (dir);
			//array [myX][myY]='R';	
		}else if (openStright(array,myX,myY,dir) && wallOnlyRight(array,myX,myY,dir)){
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location
		}else if (openStright(array,myX,myY,dir) && breadCrumOnlyRight(array,myX,myY,dir)){
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location
		}else if (wallStright(array,myX,myY,dir) && openRight(array,myX,myY,dir)){
			dir = turnRight (dir);
			//array [myX][myY]='R';										//test location
		}else if (wallStright(array,myX,myY,dir) && wallOnlyRight(array,myX,myY,dir)){
			dir = turnLeft (dir);
			//array [myX][myY]='L';										//test location
		}else if (wallStright(array,myX,myY,dir) && breadCrumOnlyRight(array,myX,myY,dir)){
			dir = turnRight (dir);
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location		
		}else if (breadCrumStright(array,myX,myY,dir) && openRight(array,myX,myY,dir)){
			dir = turnRight (dir);
			//array [myX][myY]='R';										//test location
		}else if (breadCrumStright(array,myX,myY,dir) && wallOnlyRight(array,myX,myY,dir)){
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location		
		}else if (breadCrumStright(array,myX,myY,dir) && breadCrumOnlyRight(array,myX,myY,dir)){
			dir = turnRight (dir);
			step(&myX,&myY,dir);
			//array [myX][myY]=dir;										//test location		
		}
	}
}
Doors_Controller::Doors_Controller(SubteStatus *subte, SingleButton *openLeftDoors, SingleButton *closeLeftDoors, SingleButton *selectLeftDoors, SingleButton *openRightDoors, SingleButton *closeRightDoors, SingleButton *selectRightDoors, SingleButton *silbato)
    : Base_Controller(subte)
{   
    m_selectLeftDoors = selectLeftDoors;
    m_openLeftDoors = openLeftDoors;
    m_closeLeftDoors = closeLeftDoors;
    m_selectRightDoors = selectRightDoors;
    m_openRightDoors = openRightDoors;
    m_closeRightDoors = closeRightDoors;
    m_silbato = silbato;

    m_closeRightDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png"));
    m_closeLeftDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png"));
    m_openRightDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png"));
    m_openLeftDoors->setButtonImage(QUrl("qrc:/resources/greenON.png"),QUrl("qrc:/resources/green.png"));
    m_silbato->setButtonImage(QUrl("qrc:/resources/blueON.png"),QUrl("qrc:/resources/blueplane.png"));

    m_closeLeftDoors->setLightManagement(false);
    m_closeRightDoors->setLightManagement(false);
    m_openLeftDoors->setLightManagement(false);
    m_openRightDoors->setLightManagement(false);

    turnOn();

    connect(m_closeLeftDoors,SIGNAL(buttonClicked()),this,SLOT(closeLeft()));
    connect(m_openLeftDoors,SIGNAL(buttonClicked()),this,SLOT(openLeft()));
    connect(m_closeRightDoors,SIGNAL(buttonClicked()),this,SLOT(closeRight()));
    connect(m_openRightDoors,SIGNAL(buttonClicked()),this,SLOT(openRight()));

    connect(m_selectLeftDoors,SIGNAL(buttonClicked()),this,SLOT(enableLeftPanel()));
    connect(m_selectRightDoors,SIGNAL(buttonClicked()),this,SLOT(enableRightPanel()));

    connect(m_subte,SIGNAL(DoorsChanged(bool)),this,SLOT(updatePanel(bool)));
}
ParameterStereogram::ParameterStereogram(std::tr1::shared_ptr<AbstractTexture> texture)
	: ParameterAbstractTexture(texture)
{
	QGroupBox * b = new QGroupBox(this);
	QGridLayout * g = new QGridLayout(b);
	b->setTitle(tr("Stereogram"));
	b->setLayout(g);
	g->addWidget(new QLabel(tr("Depth:")), 0, 0);
	g->addWidget(new QLabel(tr("Left:")), 1, 0);
	g->addWidget(new QLabel(tr("Right:")), 2, 0);
	g->addWidget(new QLabel(tr("Offset:")), 3, 0);
	linePathDepth_ = new QLineEdit();
	linePathLeft_ = new QLineEdit();
	linePathRight_ = new QLineEdit();
	pbDepth_ = new QPushButton("...");
	pbLeft_ = new QPushButton("...");
	pbRight_ = new QPushButton("...");
	pbDepth_->resize(26, 26);
	pbLeft_->resize(26, 26);
	pbRight_->resize(26, 26);
	lineOffset_ = new QLineEdit();
	lineOffset_->setAlignment(Qt::AlignRight);
	comboStyle_ = new QComboBox(this);
	comboStyle_->addItem("Convex");
	comboStyle_->addItem("Concave");
	g->addWidget(linePathDepth_, 0, 2, 1, 2);
	g->addWidget(linePathLeft_, 1, 2, 1, 2);
	g->addWidget(linePathRight_, 2, 2, 1, 2);
	g->addWidget(pbDepth_, 0, 4);
	g->addWidget(pbLeft_, 1, 4);
	g->addWidget(pbRight_, 2, 4);
	g->addWidget(lineOffset_, 3, 2, 1, 3);
	g->addWidget(comboStyle_, 4, 2, 1, 3);
	g->setRowStretch(5, 1);

	addWidget(b);

	connect(linePathDepth_, SIGNAL(editingFinished()),
			this, SLOT(pathDepthEdited()));
	connect(linePathLeft_, SIGNAL(editingFinished()),
			this, SLOT(pathLeftEdited()));
	connect(linePathRight_, SIGNAL(editingFinished()),
			this, SLOT(pathRightEdited()));
	connect(lineOffset_, SIGNAL(editingFinished()),
			this, SLOT(offsetEdited()));
	connect(comboStyle_, SIGNAL(activated(int)),
			this, SLOT(styleActivated(int)));
	connect(pbDepth_, SIGNAL(clicked()),
			this, SLOT(openDepth()));
	connect(pbLeft_, SIGNAL(clicked()),
			this, SLOT(openLeft()));
	connect(pbRight_, SIGNAL(clicked()),
			this, SLOT(openRight()));

	reloadData();
}
Exemple #4
0
bool Labyrinth::openDoor(const position &from, const Labyrinth::Direction &direction)
{
    bool isValid = false;
    auto cell = this->cells.at(from).get();
    auto neighborPosition = this->getNeighbor(from, direction, isValid);

    // neighboor invalid, next
    if (!isValid) {
        return false;
    }

    auto neighborCell = this->cells.at(neighborPosition).get();

    // open door
    switch (direction)
    {
        case Direction::BOTTOM:
            cell->openBottom();
            break;

        case Direction::RIGHT:
            cell->openRight();
            break;

        case Direction::TOP:
            neighborCell->openBottom();
            break;

        case Direction::LEFT:
            neighborCell->openRight();
            break;
    }

    this->updateWays(cell->way, neighborCell->way);

    return true;
}
Exemple #5
0
void dimv::createActions() {
	openLeftAct = new QAction(tr("Open left..."), this);
	openLeftAct->setShortcut(tr("Ctrl+L"));
	connect(openLeftAct, SIGNAL(triggered()), this, SLOT(openLeft()));

	openRightAct = new QAction(tr("Open right..."), this);
	openRightAct->setShortcut(tr("Ctrl+R"));
	connect(openRightAct, SIGNAL(triggered()), this, SLOT(openRight()));

	zoomInAct = new QAction(tr("Zoom in"), this);
	zoomInAct->setShortcut(Qt::Key_Plus);
	connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

	zoomOutAct = new QAction(tr("Zoom out"), this);
	zoomOutAct->setShortcut(Qt::Key_Minus);
	connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

	normalSizeAct = new QAction(tr("Original size"), this);
	normalSizeAct->setShortcut(tr("Ctrl+0"));
	connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

	leftAct = new QAction(this);
	leftAct->setShortcut(Qt::Key_Left);
	connect(leftAct, SIGNAL(triggered()), this, SLOT(left()));

	rightAct = new QAction(this);
	rightAct->setShortcut(Qt::Key_Right);
	connect(rightAct, SIGNAL(triggered()), this, SLOT(right()));

	upAct = new QAction(this);
	upAct->setShortcut(Qt::Key_Up);
	connect(upAct, SIGNAL(triggered()), this, SLOT(up()));

	downAct = new QAction(this);
	downAct->setShortcut(Qt::Key_Down);
	connect(downAct, SIGNAL(triggered()), this, SLOT(down()));

	exitAct = new QAction(tr("Close"), this);
	exitAct->setShortcut(Qt::Key_Escape);
	connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

	aboutAct = new QAction(tr("&About"), this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}