当前位置: 首页>>代码示例>>C++>>正文


C++ Floor类代码示例

本文整理汇总了C++中Floor的典型用法代码示例。如果您正苦于以下问题:C++ Floor类的具体用法?C++ Floor怎么用?C++ Floor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Floor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: move

void Swan::move(Floor& floor){
	location deltaPos, current, next;
	int input;
	current = getPos();
	
	do{
		deltaPos.r = 0;
		deltaPos.c = 0;
		next = current;
		input = rand()%4;
		if(input == 0){
			deltaPos.r--;
		}
		else if(input == 1){
			deltaPos.c--;
		}
		else if(input == 2){
			deltaPos.r++;
		}
		else if(input == 3){
			deltaPos.c++;
		}

		next.r += deltaPos.r;
		next.c += deltaPos.c;
	}while(invalidMove(next, floor));

	floor.setTile(current.r, current.c, getTileBelow());
	if(getTileBelow() == 'P')
		floor.setTile(current.r, current.c, ' ');
	setTileBelow(floor.getTile(next.r, next.c));

	setPos(next);
	floor.setTile(next.r, next.c, 'S');
}
开发者ID:millelog,项目名称:Escape-ASCII-Game,代码行数:35,代码来源:Swan.cpp

示例2: oss

void Person::RequestFloor(Environment &env) {

	Floor *next = path_.front();

	if (!next) {
		std::ostringstream oss("Invalid operation: no next floor in path ", std::ostringstream::ate);
		oss << "ID of person: <" << GetId();
		oss << ", this error should never occur.";
		throw std::runtime_error(oss.str());
	}

	for (int i = 0; i < elevator_->GetInterfaceCount(); ++i) {

		Interface *interf = elevator_->GetInterface(i);
		Floor *floor = static_cast<Floor*>(interf->GetLoadable(0));

		if (floor == next) {
			action_ = env.SendEvent("Interface::Interact", 3, this, elevator_->GetInterface(i));

			return;
		}
	}

	std::ostringstream oss("Invalid operation: ", std::ostringstream::ate);
	oss << elevator_->GetName() << " can not go to Floor " << next->GetId();
	oss << ", this error should never occur.";
	throw std::runtime_error(oss.str());
}
开发者ID:ChrisDue,项目名称:Elevator,代码行数:28,代码来源:Person.cpp

示例3: extrude_envelope

Surface* Building::extrude_lod3(double hFloor, double lenHasWin, double lenUnit) const
{
    Surface* bldg = extrude_envelope();
    for(int i=0;i<bldg->getNumChildren();++i)
    {
        if(bldg->getChild(i)->getType()==SurfaceType::Wall)
        {
            Wall* wall = (Wall*)(bldg->getChild(i));
            wall->splitFloor(hFloor);
            double lWall = wall->getLength();
            if(lWall>lenHasWin || std::abs(lWall-lenHasWin)<0.001)
            {
                for(int j=0;j<wall->getNumChildren();++j)
                {
                    Floor* floor = (Floor*)(wall->getChild(j));
                    floor->splitUnit(lenUnit);
                    for(int k=0;k<floor->getNumChildren();++k)
                    {
                        Unit* unit = (Unit*)(floor->getChild(k));
                        if(j==0 && k%5 == 0 && unit->getLength()>3)
                        {
                            unit->insertDoor(unit->getLength()/3,unit->getHeight()*2/3);
                            continue;
                        }

                        if(unit->getLength()>1)
                            unit->insertWindow(unit->getLength()/3,unit->getHeight()/3);
                    }
                }
            }

        }
    }
    return bldg;
}
开发者ID:HEShuang,项目名称:BuildUP,代码行数:35,代码来源:Building.cpp

示例4: onKeyPress

void onKeyPress(unsigned char key, int x, int y) {
    switch (key) {
    //exit
    case 27:
        exit(0);
        break;
    //fullscreen
    case 'f': {
        if (fullscreen = !fullscreen) glutFullScreen();
        else {
            glutReshapeWindow(400, 455);
            glutPositionWindow(50, 50);
        }
        break;
    }
    //light - night
    case 'n':
        lights.switchLight();
        break;
    //pause
    case 'p':
        paused = !paused;
        break;
    //reset
    case 'r':
        maze = Maze();
        break;
    //cam1
    case '1':
        cams.enable(CAM_FLAT);
        break;
    case '2':
        cams.enable(CAM_1);
        break;
    case '3':
        cams.enable(CAM_2);
        break;
    case '4':
        cams.enable(CAM_FOLLOW);
        break;
    case '5':
        cams.enable(CAM_FOLLOW2);
        break;
    case '6':
        cams.enable(CAM_FOLLOW2_NEAR);
        break;
    case '7':
        cams.enable(CAM_BILU);
        break;
    case '8':
        cams.enable(CAM_MOVE);
        break;

    case 'z':
        mazeFloor.switchFloor(mazeFloor.getactiveFloor());
        break;
    }
    cams.onKeyPress(key);
}
开发者ID:joaoB,项目名称:Pacman,代码行数:59,代码来源:main.cpp

示例5: onAllLoaded

void FloorFace::onAllLoaded() {
	Object::onAllLoaded();
	Floor *floor = Object::cast<Floor>(_parent);

	for (uint i = 0; i < ARRAYSIZE(_indices); i++) {
		_vertices[i] = floor->getVertex(_indices[i]);
	}
}
开发者ID:ComputeLinux,项目名称:residualvm,代码行数:8,代码来源:floorface.cpp

示例6: while

void GameScene::initFloorsAndCoins()
{
    int num = 0;//用来作为数组下标
    int count = 0;//用来控制山体的X坐标
    
    isFrontBlank = false;
    
    //创建20个山体和金币,放入数组中
    for (int i=0; i<floorCount; i++) {
        Floor *floor = Floor::createFloor();
        floor->setScale(scaleFix);
        this->addChild(floor);
        floorArray.pushBack(floor);
        
       Coin *coin = Coin::createCoin();
       this->addChild(coin);
       coinArray.pushBack(coin);
        
    }
    //循环遍历修改山体和金币的位置
    while (num<floorCount) {
        count++;
        if (num<floorCount/2) {
            //前10个山体和金币单独处理,count用来控制位置,根据player的初始化位置设置地面的位置
            floorArray.at(num)->setPosition(Point(count*35,winSize.height/2 -100));
            
            Floor *floortemp = floorArray.at(num);
            //金币放在山体上方一定距离
            coinArray.at(num)->setPosition(Point(count*35,floortemp->getPositionY()+80));
            num++;
        }else{
            //后10个山体和金币的处理
            randomNum = this->getRandomNumber(0, 2); //0~2的随机数
            if (randomNum == 0) {
                isFrontBlank = true;
                continue;
            }
            if (isFrontBlank) {
                //山体高度设置为100到320-220即100之间的随机数
                floorArray.at(num)->setPosition(Point(count*35, this->getRandomNumber(winSize.height/2 -100, 180)));
                //金币高度设置为山体以上30到100的高度
                float y = floorArray.at(num)->getPositionY() + this->getRandomNumber(50, 150);
                coinArray.at(num)->setPosition(Point(count*35, y));
                
                isFrontBlank = false;
            }else{
                //设置山体的高度为前一个山体的高度
                floorArray.at(num)->setPosition(Point(count*35, floorArray.at(num -1)->getPositionY()));
                
                //金币的高度为山体以上30到100的高度
                float y = floorArray.at(num)->getPositionY() + this->getRandomNumber(50, 150);
                coinArray.at(num)->setPosition(Point(count*35, y));
            }
            num++;
        }
    }
}
开发者ID:2011conquer,项目名称:MikuRun2,代码行数:57,代码来源:GameScene.cpp

示例7: Floor

void WorldGenerator::AddFloor( float _x, float _y )
{
	Floor* floor = new Floor();
	floor->mPosition = D3DXVECTOR3( _x, -100, _y );
	floor->mModel = mResources->getModel( 801 );
	floor->Initialize( md3dManager );

	mGFS->mFloor.push_back( floor );
}
开发者ID:ChristofferJon,项目名称:pacmanhorror,代码行数:9,代码来源:WorldGenerator.cpp

示例8: nextCommand

Command *Command::opEnableFloorField(const ResourceReference &floorFieldRef, bool enable) {
	FloorField *floorField = floorFieldRef.resolve<FloorField>();
	Layer *layer = floorField->findParent<Layer>();
	Floor *floor = layer->findChild<Floor>();

	floor->enableFloorField(floorField, enable);

	return nextCommand();
}
开发者ID:DouglasLiuGamer,项目名称:residualvm,代码行数:9,代码来源:command.cpp

示例9: updateFloorsAndCoins

void GameScene::updateFloorsAndCoins()
{
    //改变山体的位置
    for (int i =0; i<floorArray.size(); i++) {
        Floor *floor = floorArray.at(i);
        //forceX=300,speedFix = 0.01
        floor->setPosition(Point(floor->getPositionX()-forceX * speedFix, floor->getPositionY()));
    }
    //改变金币的位置
    for (int i = 0; i<coinArray.size(); i++) {
        Coin *coin = coinArray.at(i);
        coin->setPosition(Point(coin->getPositionX()-forceX * speedFix, coin->getPositionY()));
    }
    
    //当第一个山体移出屏幕
    if (floorArray.at(0)->getPositionX() <-50) {
        int num = floorArray.size()-1;//数组中最后一个元素下标
        float posx = floorArray.at(num)->getPositionX();//获取最后一个山体的X坐标
        
        //将第一个山体再加入数组中,这样它就成为最后一个元素
        floorArray.pushBack(floorArray.at(0));
        
        //删除数组中第一个元素,这样就完成了第一个山体移动到数组中最后的位置
        floorArray.eraseObject(floorArray.at(0));
        
        coinArray.pushBack(coinArray.at(0));
        coinArray.eraseObject(coinArray.at(0));
        
        //获取0~2的随机数
        randomNum = this->getRandomNumber(0, 2);
        if (randomNum == 0) {
            isFrontBlank = true;
            randomNum = this->getRandomNumber(1, 4);
        }
        
        Coin *coin = coinArray.at(num);
        //数组中最后一个元素,即原来的第一个元素移动到最后位置,再获取最后一个
       
        coin->setVisible(true);
        if (isFrontBlank) {
            //posx为数组中倒数第二个元素的X坐标,高度为随机数100~150之间
            //设置新的最后一个元素的位置
            floorArray.at(num)->setPosition(Point(posx + randomNum*35 + 35, this->getRandomNumber(winSize.height/2 -100,170)));
            coinArray.at(num)->setPosition(Point(posx + randomNum*35 + 35, floorArray.at(num)->getPositionY() + this->getRandomNumber(50, 150)));
            isFrontBlank = false;
        }else{
            //X轴坐标后移,高度同前一个山体
            floorArray.at(num)->setPosition(Point(posx + 35 , floorArray.at(num - 1)->getPositionY()));
            coinArray.at(num)->setPosition(Point(posx +  35, floorArray.at(num)->getPositionY() + this->getRandomNumber(50, 150)));
        }
        randomNum = this ->getRandomNumber(0, 2);
        if (randomNum == 0) {
            coin->setVisible(false);
        }
    }
}
开发者ID:2011conquer,项目名称:MikuRun2,代码行数:56,代码来源:GameScene.cpp

示例10:

CCArray *Building::getTransferFloors(){
    CCArray *transferFloors = CCArray::create();
    
    for(int i = 0; i < this->arrayFloors->count(); i++){
        Floor *floor = (Floor *)this->arrayFloors->objectAtIndex(i);
        if(floor->getTransferLeft() || floor->getTransferRight()){
            transferFloors->addObject(floor);
        }
    }
    
    return transferFloors;
}
开发者ID:rossimrc,项目名称:AlbertEinstein,代码行数:12,代码来源:Building.cpp

示例11: Floor

Floor *Floor::create(int ID, CCString *name, int floorNumber, bool transferRight, bool transferLeft){
	Floor *f = new Floor(ID, name, floorNumber, transferRight, transferLeft);
	f->autorelease();
	
	if(!arrayFloors){
		arrayFloors = CCDictionary::create();
		arrayFloors->retain();
	}
		
	arrayFloors->setObject(f, ID);
    return f;
}
开发者ID:camargomorphy,项目名称:AlbertEinstein,代码行数:12,代码来源:Floor.cpp

示例12: stepOntoFloor

// person walks onto a floor
void Person::stepOntoFloor( Floor& floor )  
{
   // notify floor a person is coming
   cout << "person " << ID << " steps onto floor " 
        << floor.getNumber() << endl;
   floor.personArrives( this );

   // press button on the floor
   cout << "person " << ID 
        << " presses floor button on floor " 
        << floor.getNumber() << endl;
   floor.floorButton.pressButton();
}
开发者ID:tjyang,项目名称:abmon,代码行数:14,代码来源:person.cpp

示例13: main

int main(int argc, char** argv) {
    srand(lastUpdate);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(400, 455);
    glutInitWindowPosition(-1, -1);
    glutCreateWindow("Pac-Man");
    glutDisplayFunc(onDisplay);
    glutReshapeFunc(onReshape);
    glutSpecialFunc(onSpecialKeyPress);
    //glutSpecialUpFunc(onSpecialKeyUp);
    glutKeyboardFunc(onKeyPress);
    glutIdleFunc(onIdle);

    //glutIgnoreKeyRepeat(true);
    glEnable(GL_DEPTH_TEST);
    glPolygonMode(GL_FRONT, GL_FILL);

    mazeFloor.load();



    glutMainLoop();
    return 0;
}
开发者ID:joaoB,项目名称:Pacman,代码行数:25,代码来源:main.cpp

示例14: currentFloor

Elevator::Elevator(Floor &flr1, Floor &flr2)
:  currentFloor(flr1.getNumber()),
	destFloor(flr1.getNumber()),
	floor1(flr1),
	floor2(flr2),
	personPtr(0),
	moving(false),
	doors(),
	bell(),
	currentTime(0),
	arrivalTime(0),
	movingDirection(NO),
	elevatorbutton(*this)
{
	cout << "Elevator was created." << endl;
}
开发者ID:tergum,项目名称:Elevator,代码行数:16,代码来源:Elevator.cpp

示例15: exitElevator

// person exits elevator
void Person::exitElevator( 
   const Floor &floor, Elevator &elevator ) const
{
   cout << "person " << ID << " exits elevator on floor "
        << floor.getNumber() << endl;
   elevator.passengerExits();
}
开发者ID:tjyang,项目名称:abmon,代码行数:8,代码来源:person.cpp


注:本文中的Floor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。