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


C++ Fish::getPosition方法代码示例

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


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

示例1: display

void Scene::display() {
	// Clear screen, initialise culling
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Select model view matrix
	glMatrixMode(GL_MODELVIEW);

	// Draw solid bodies
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glLoadIdentity();

	Fish* f = Fish::getFirst();
	Vector* v = f->getPosition();
	GLfloat lightPos[] = { static_cast<GLfloat>(v->x),
		static_cast<GLfloat>(v->y - 10), static_cast<GLfloat>(v->z), 1.0 };
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

	// args 1-3: viewer coordinates,
	// args 4-5: point looked at,
	// args 7-9: "up" vector
	gluLookAt(
		camPos[activeCam]->x, camPos[activeCam]->y, camPos[activeCam]->z,
		0.0, 20.0, 0.0,
		0.0, 1.0, 0.0);

	// Draw scene graph
	fishList->work();
	if (!calculateFishCount) {
		sharkList->work();
	}
	graph->work();

	if (drawNames) {
		Text::drawAll();
	} else {
		fpsDisplay->draw();
		for (list<Text*>::iterator it = helpDisplay.begin(); it != helpDisplay.end(); it++) {
			(*it)->draw();
		}
	}

	glFlush();
	glutSwapBuffers();

	if (calculateFishCount) {
		glutPostRedisplay();
	}
	frames++;
}
开发者ID:atextor,项目名称:fishtank,代码行数:50,代码来源:Scene.cpp

示例2: XMTMoveAI


//.........这里部分代码省略.........
                Fish* fish = Fish::createFish(1,
                                              Vec2(25 + 700 * rd2, 1334),
                                              level,
                                              gData->_minRunSpeed + 200 * rd3,
                                              true,
                                              nullptr);
                fish->setTag(OBJ_FISH);
                playLayer->apiAddFish(fish);
                
            }
        }
        
        if(disRemainder4Block == 0 && disDivisor4Block != _disDivisor4Block)
        {
            // create block
            _disDivisor4Block = disDivisor4Block;
            
            // create fish
            float rd2 = CCRANDOM_0_1();
            
            float x = 25 + 700 * rd2;
            
            log("create block");
            
            BFBlock* block = BFBlock::createBlock(Vec2(x, 1334));
            block->setTag(OBJ_BLOCK);
            playLayer->apiAddBlock(block);
        }
    }
    
    Fish* player = playLayer->xGetPlayer();
    // collision detection
    {
        Vec2 pPos = player->getPosition();
        gData->_playerPosY = pPos.y;
        
        Rect pRect = player->getBoundingBox();
        Vector<Node*>& children = playLayer->getChildren();
        for(auto a : children)
        {
            if((a->getTag() & OBJ_FISH) == OBJ_FISH)
            {
                Fish* fish = (Fish*)a;
                Rect fRect = fish->getBoundingBox();
                if(fRect.intersectsRect(pRect))
                {
                    if(fish->GetLevel() > player->GetLevel())
                    {
                        // game over
                        gData->_healthPoint = 0;
                        JizGame::getInstance()->playAudioEffect("audioeffect/hurt2.mp3");
                    }
                    else
                    {
                        JizGame::getInstance()->playAudioEffect("audioeffect/eat1.mp3");
                        gData->_experience += (10 + fish->GetLevel());
                        gData->_eatedCount++;
                        gData->_staminaPoint += gData->_staminaRecoverPoint* fish->GetLevel();
                        
                        // eat fish
                        gData->_staminaPoint += 10;
                        
                        fish->Die();
                        fish->setTag(OBJ_ORNAMENTAL);
                        
                        auto layerEffect = (XEffectLayer*)playLayer->getChildByTag(LAYER_EFFECT);
开发者ID:Stringbao,项目名称:bigfish,代码行数:67,代码来源:M001Logic.cpp

示例3: checkCollision

void GameScene::checkCollision(){
    std::vector<int> catched;
    
    for (int i = 0; i < _fish.size(); i++) {
        Fish *fish = _fish.at(i);
        if (!fish->getIsCatched()) {
            Point fishPoint = fish->getPosition();
            Size fishSize = Size(fish->getContentSize().width * fabs(fish->getScaleX()), fish->getContentSize().height * fabs(fish->getScaleY()));
            Point hookpoint = _fisherman->getHookWorldPoint();
            
            bool x = false;
            bool y = false;
            
            if (((fishPoint.x - (fishSize.width/2)) < hookpoint.x) &&
                ((fishPoint.x + (fishSize.width/2)) > hookpoint.x)) {
                x = true;
            }
            
            if (((fishPoint.y - (fishSize.height/2)) < hookpoint.y) &&
                ((fishPoint.y + (fishSize.height/2)) > hookpoint.y)) {
                y = true;
            }
            
            if (x && y) {
                catched.push_back(i);
            }
        }
    }
    
    for (int i = 0; i < catched.size(); i++) {
        int x = catched.at(i);
        Fish *f = _fish.at(x);
        if(f != _catchedFish) {
            f->setIsCatched(true);
            if (!_catchedFish) {
                CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("new_pick_up.wav");
                _catchedFish = f;
                _catchedFish->setPreventAnimations(true);
                _catchedFish->setRotation(_catchedFish->getScaleX() > 0 ? 90 : 270);
                _scoreMultiplier = 1;
                
                _currentScore = _catchedFish->getScore();
                
            } else {
                if (!dynamic_cast<Turtle*>(f)) {
                    CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("new_pick_up.wav");
                    _scoreMultiplier ++;
                    
                    if (f->getScore() > _catchedFish->getScore()) {
                        //                f->setScore(f->getScore());
                        _fish.erase(std::remove(_fish.begin(), _fish.end(), _catchedFish), _fish.end());
                        _catchedFish->removeFromParent();
                        _catchedFish = NULL;
                        
                        
                        _catchedFish = f;
                        _currentScore += _catchedFish->getScore();
                        _catchedFish->setPreventAnimations(true);
                        _catchedFish->setRotation(_catchedFish->getScaleX() > 0 ? 90 : 270);
                        
                    } else {
                        _currentScore += f->getScore();
                        _fish.erase(std::remove(_fish.begin(), _fish.end(), f), _fish.end());
                        f->removeFromParent();
                        f = NULL;
                        
                    }

                }
                
                
            }

        }
        
        
    }
    
    if (_currentScore > 0) {
        char buff[100];
        sprintf(buff, "%dX%i", (int)roundf(_currentScore),(int)_scoreMultiplier);
        std::string buffAsStdStr = buff;
        _currentLabel->setString(buffAsStdStr);
        
    }
    
}
开发者ID:areschoug,项目名称:LD29,代码行数:87,代码来源:GameScene.cpp


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