本文整理汇总了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');
}
示例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());
}
示例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;
}
示例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);
}
示例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]);
}
}
示例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++;
}
}
}
示例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 );
}
示例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();
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}