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


C++ Helicopter类代码示例

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


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

示例1: foreach

void Bullet::checkCollision()
{
    QList<QGraphicsItem *> l=scene()->items();
    foreach(QGraphicsItem *item, l) {
        if ( (item->type()==man_type) && item->collidesWithItem(this, Qt::IntersectsItemBoundingRect) ) {
            Man* deadman = (Man*)item;
            if (deadman->frame() != 5) return;
            deadman->done();
            emit score(10);
            setShotCount(shotcount+1);
            nobullets--;
            deleteLater();
            return;
        }
        else if ( (item->type()==helicopter_type) && item->collidesWithItem(this, Qt::IntersectsItemBoundingRect) ) {
            Helicopter* deadchopper = (Helicopter*) item;
            deadchopper->done();
            emit score(50);
            setShotCount(shotcount+1);
            nobullets--;
            deleteLater();
            return;
        }
    }
    //check shot is not out of bounds
    if ( (y() < 0) || (x() < 0) ||
        (y() > scene()->height()) ||
        ( x() > scene()->width()))  {
        nobullets--;
        deleteLater();
        return;
    }
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:33,代码来源:bullet.cpp

示例2: if

void GameWorld::update(float delta) {

    scoreTextLabel->setPosition(this->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(ccp(100, 100))));
    
    scoreLabel->setString(std::to_string(scoreManager->getScore()));
    pointlocation = this->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(ccp(110, 130)));
    scoreLabel->setPosition(pointlocation);
    
    heartsprite->setPosition(this->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(ccp(30, 60))));
    
    healthLabel->setString(std::to_string(player->currentHealth));
	healthLabel->setPosition(this->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(ccp(114, 60))));
    
    //Update the player.
    player->update(delta);
    
    //Update all the npcs.
    for (Entity* e : *npcManager->getNpcs()) {
        if (IsType<Crowd>(e)) {
            Crowd* c = static_cast<Crowd*>(e);
            c->update(delta);
        } else if (IsType<Helicopter>(e)) {
            Helicopter* h = static_cast<Helicopter*>(e);
            h->update(delta);
        } else
            e->update(delta);
    }
    
    //Update all the broken buildings.
    for (BrokenStructure* b : *structureManager->getStructures()) {
        b->update(delta);
    }
    
}
开发者ID:Soxs,项目名称:PMRGame,代码行数:34,代码来源:GameWorld.cpp

示例3: onPosto

bool onPosto(Helicopter player, Rect posto){
	if(player.getGunPosX() > posto.getX()
		&& player.getGunPosX() < (posto.getX() + posto.getWidth())
		&& player.getGunPosY() > posto.getY()
		&& player.getGunPosY() < (posto.getY() + posto.getHeight())
	){
		// on posto
		return true;
	}
	// left posto
	return false;
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:12,代码来源:Utils.cpp

示例4:

Bomb::Bomb(const Helicopter &helicopter){
	this->xCoordinate = helicopter.getXCoordinate();
	this->yCoordinate = helicopter.getYCoordinate();

	if(helicopter.getXVelocity() != 0)
		this->xVelocity = helicopter.getXVelocity();
	else
		this->xVelocity = 0;

	this->yVelocity = +4;

	this->hitbox.leftBorder = this->xCoordinate + 52;
	this->hitbox.rightBorder = this->hitbox.leftBorder + BOMB_WIDTH;
	this->hitbox.topBorder = this->yCoordinate + 25;
	this->hitbox.bottomBorder = this->hitbox.topBorder + BOMB_HEIGHT;
}
开发者ID:ajaysreenivasan,项目名称:helifire,代码行数:16,代码来源:Bomb.cpp

示例5: main

int main(int argc, char* argv[]){
	char path[255];
	if(argc != 2){
		cout << "Running at default path './config/config.xml'..." << endl;
		strcpy(path, "../config/config.xml");
	}else{
		strcpy(path, argv[1]);
		strcat(path, "config.xml");
	}
	srand(time(NULL));

	config.readXML(path);
	arena.readXMLArena((config.getArena().getPath() + config.getArena().getName() + "." + config.getArena().getExtension()).c_str());
	player = config.readHelicopterConfig(path);
	player.setArena(ARENAX, ARENAY);
	enemies.push_back(config.readEnemyHelicopter(path, ARENAX/100 * 90, ARENAY/100 * 10));
	enemies.push_back(config.readEnemyHelicopter(path, ARENAX/100 * 90, ARENAY/100 * 90));
	enemies.push_back(config.readEnemyHelicopter(path, ARENAX/100 * 10, ARENAY/100 * 90));
	enemies.at(0).setAngle(0);

	glutInit 				(&argc, argv);
	glutInitDisplayMode 	(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize 		(ARENAX,ARENAY);
	glutInitWindowPosition 	(0, 0);
	glutCreateWindow 	("Arena");
	init 				(ARENAX, ARENAY);
	glutDisplayFunc		(display);
	glutMouseFunc		(mouse);
	glutIdleFunc		(idle);
	glutKeyboardFunc 	(setKeyDown);
	glutKeyboardUpFunc 	(setKeyUp);

	//timers
	glutTimerFunc((player.getTempoDeVoo() * 1000)/5, timerGasBar, 0);
	glutTimerFunc(rand() % (int)(5 - 2 + 1),timerEnemyMovement,0);
	glutTimerFunc(200,timerEnemyShooting,200);

	glutPassiveMotionFunc(motion);
	glutMainLoop		();

}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:41,代码来源:main.cpp

示例6: score

void Bullet::checkCollision()
{
    QCanvasItem* item;
    QCanvasItemList l=collisions(FALSE);
      for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
          item = *it;
          if ( (item->rtti()== 1500) && (item->collidesWith(this)) ) {
               Man* deadman = (Man*)item;
               if (deadman->frame() != 5) return;
               deadman->done();
	       emit score(10);
               setShotCount(shotcount+1);
               setAnimated(false);
               nobullets--;
               delete this;
               return;
          }
          else if ( (item->rtti()==1900) && (item->collidesWith(this)) ) {
               Helicopter* deadchopper = (Helicopter*) item;
               deadchopper->done();
	       emit score(50);
               setAnimated(false);
               nobullets--;
               delete this;
               return;
         }
      }
      //check shot is not out of bounds
     if ( (y() < 0) || (x() < 0) ||
          (y() > canvas()->height()) ||
          ( x() > canvas()->width()))  {
          setAnimated(false);
          nobullets--;
          delete this;
          return;
     }
}
开发者ID:opieproject,项目名称:opie,代码行数:37,代码来源:bullet.cpp

示例7: checkDefeat

// true = victory
// false = defeat
bool checkDefeat(Helicopter player, float x, float y){
	string defeat = "DEFEAT";
	if(player.getGas() <= 0){
	// if(player.getGas() >10){
			glPushMatrix();
				glTranslatef(x, y, 0.0);
				glColor3f(0.0, 0.0, 0.0);
				glScalef(0.5, 0.5, 0.5);
				glRotatef(180.0, 1.0, 0.0, 0.0);
				for(int i = 0; i < 6 ; i++) glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,defeat[i]);
			glPopMatrix();
		return true;
	}
	return false;
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:17,代码来源:Utils.cpp

示例8: onArena

bool onArena(Helicopter player, Rect arena, float displacement){
	float nextMoveX = player.getNextMoveX(displacement) + player.getCx();
	float nextMoveY = player.getNextMoveY(displacement) + player.getCy();

	if(nextMoveX + player.getRadius() > arena.getWidth()
		|| nextMoveX - player.getRadius() < 0.0
		|| nextMoveY + player.getRadius() > arena.getHeight()
		|| nextMoveY - player.getRadius() < 0.0){
			// left arena
			return true;
		}
	// on arena
	return false;
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:14,代码来源:Utils.cpp

示例9: dc

void RealTimeTest::maxSpead() {
    
	Hud *maxSpeadTestingHud = game.getHudsManager()->createHud(HudAlignment::RIGHT);
	maxSpeadTestingHud->setText("MAX SPEAD TESTING STARTED...");
	
	DelayCommand dc(15);
	dc.execute();
	
	Helicopter *helicopter = game.getHelicopter();
	JoystickMoveForward jmf(helicopter->getJoystick());
	RotorNeutral rn(helicopter->getMainRotor());
	float oldV = 0;
	float newV = 0;
	
	std::cout << "\nmaxSpead test started:" << std::endl;
	
	game.getConfiguration()->activateFriction();
	helicopter->reset();
	helicopter->setPosistion(osg::Vec3f(0, 0, 600));
	jmf.execute();
	rn.execute();
	
	
	do {
		oldV = newV;
		dc.execute();
		newV = helicopter->getVelocity().x();
	} while (oldV < newV);
	
	
	// viscous resistance = v * (6 * WORLD_PI * 0.001 * 4)
	// if joystick(theta = 15, phi = 0) and throttle(9.8), then
	// ax = sin15 * 9.8 = 0.2588 * 9.8 = 2.53624
	// viscous resistance should be equal 2.53624
	// v * (6 * WORLD_PI * 0.001 * 4) = 2.53624 <= now solve for v
	// v = 2.53624 / (6 * WORLD_PI * 0.001 * 4)
	// v = 33.6379
	Assert(33.6379, helicopter->getVelocity().x(), 0.01);
	
	std::cout << "maxSpead test passed" << std::endl;
	std::cout << "maxSpead test results:" << std::endl;
	std::cout << "vx = " << helicopter->getVelocity().x() << std::endl;
    maxSpeadTestingHud->setText("HOVER TESTING PASSED...");
}
开发者ID:hamadmarri,项目名称:Helicopter-Game-on-OSG,代码行数:44,代码来源:RealTimeTest.cpp

示例10: main

int main(int argc, char** argv) {
	playerInstance->setX(800);
	playerInstance->setZ(1000);
	playerInstance->setY(0);
	playerInstance->setHeight(PLAYER_EYE_HEIGHT);
	int seed = 1268511395;
	srand(seed);
	cout << "*Using seed: " << seed << endl;
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	
	//http://www.swiftless.com/tutorials/opengl/fullscreen.html
	//glutGameModeString( "1920x1080:[email protected]" ); //the settings for fullscreen mode
    //glutEnterGameMode(); //set glut to fullscreen using the settings in the line above
	
	glutInitWindowSize (1280,800);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("Simple Window"); 


	initRendering();

	
	string name = textureDir;
	name += "heightmap.bmp";
//	_terrain = loadTerrain(name.c_str(), 20);

	int bunkerTextures[] = {_textureFront, _textureRight, _textureBack, _textureLeft};
	
	// For testing purposes:
	// /*
	int * testcoords = playerInstance->getGridCoords();	
	cout << testcoords[0] << "," << testcoords[1] << endl;
	mapInstance->mark(testcoords[0],testcoords[1],5);
	
	//***/
	// write maps
	mapInstance->writeToFile("map.txt");

	bunker1 = Bunker(HORI_SIZE, VERTI_SIZE, 800, 0, 1200, bunkerTextures);
	bunker2 = Bunker(HORI_SIZE, VERTI_SIZE, 1100, 0, 1200, bunkerTextures);
	atom1 = Atom(600.0f, PLAYER_EYE_HEIGHT, 1200.0f, 14); //Si
	atom2 = Atom(650.0f, PLAYER_EYE_HEIGHT, 1200.0f, 8);  //Oxygen
	atom3 = Atom(700.0f, PLAYER_EYE_HEIGHT, 1200.0f, 1);  //Hydrogen
	building1 = Building(1300, 0, 1200, 200, 100, 60, _textureBuilding);

	
	// testing purposes:
	mapInstance->writeToFile("map2.txt");

	hunter1 = new Necromancer(800,0.0f,1300.0f);

	int waypoints[6*4] = {
		1000, 6*PLAYER_EYE_HEIGHT, 1000,
		3000, 4*PLAYER_EYE_HEIGHT, 3000,
		3000, 6*PLAYER_EYE_HEIGHT, 1000,
		1000, 4*PLAYER_EYE_HEIGHT, 3000,
		1000, 6*PLAYER_EYE_HEIGHT, 1000,
		2500, 4*PLAYER_EYE_HEIGHT, 2500
	};
	int k = 0;
	for(k = 0; k<12; k++) {
		cout << waypoints[k] << endl;
	}

	int numWaypoints = 6;
	FlightPath fp = FlightPath(waypoints, numWaypoints, true);

	heli = Helicopter(200.0f, 4*PLAYER_EYE_HEIGHT, 200.0f);
	heli.setFlightPath(fp);

	sittingDuck1 = SittingDuck(800.0f, PLAYER_EYE_HEIGHT, 100.0f, 5);
	duckList.push_back(sittingDuck1);

	glutDisplayFunc(drawScene);
	glutKeyboardFunc(handleKeypress);
	glutKeyboardUpFunc(handleKeyrelease);
	glutPassiveMotionFunc(mouseMotion);
	glutReshapeFunc(handleResize);
	glutTimerFunc(25, update, 0);
	glutMainLoop();
	return 0;
}
开发者ID:sennheiser1986,项目名称:oglproject,代码行数:83,代码来源:main.cpp

示例11: idle

void idle(){
	static GLdouble previousTime = 0;
    GLdouble currentTime;
    GLdouble timeDifference;

    currentTime = glutGet(GLUT_ELAPSED_TIME);
    timeDifference = currentTime - previousTime;
    previousTime = currentTime;

	// key control
	if(keys['a'] == 1 || keys['A'] == 1) player.rotate(-player.getVelHelicoptero() * timeDifference);
	if(keys['d'] == 1 || keys['D'] == 1) player.rotate(player.getVelHelicoptero() * timeDifference);
	if(keys['w'] == 1 || keys['W'] == 1){
		// checks if next position exceeds boudaries
		if(!onArena(player, arena.getArena(), -player.getVelHelicoptero() * timeDifference))
			player.moveY(-player.getVelHelicoptero() * timeDifference);
	}
	if(keys['s'] == 1 || keys['S'] == 1){
		// checks if next position exceeds boudaries
		if(!onArena(player, arena.getArena(), player.getVelHelicoptero() * timeDifference))
			player.moveY(player.getVelHelicoptero() * timeDifference);
	}
	if(keys['+'] == 1) player.moveHelice(0.1 * timeDifference);
	if(keys['-'] == 1) player.moveHelice(-0.1 * timeDifference);

	// enemies conditional movement
	for(int i = 0; i < enemies.size() ; i++){
		float rndm = 40 + (rand() % (int)(180 - 40 + 1));
		float vel= -enemies.at(i).getVelHelicoptero() * timeDifference;
		if(onEnemy(enemies, i)){
			enemies.at(i).setCollided(true);
		}else{
			enemies.at(i).setCollided(false);
		}
		if(!enemies.at(i).getCollided() && !onArena(enemies.at(i), arena.getArena(), vel)){
			enemies.at(i).moveY(vel);
		}else{
			enemies.at(i).rotate(rndm);
			enemies.at(i).moveY(vel);
			enemies.at(i).setCollided(false);
		}
	}

	glutPostRedisplay();
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:45,代码来源:main.cpp

示例12: motion

void motion(int x, int y){

	static GLdouble previousTime = 0;
    GLdouble currentTime;
    GLdouble timeDifference;
    currentTime = glutGet(GLUT_ELAPSED_TIME);
    timeDifference = currentTime - previousTime;
    previousTime = currentTime;

	if(mouseX < x ) player.rotateGun(timeDifference* 0.1);
	if(mouseX > x )	player.rotateGun(timeDifference* -0.1);
	mouseX = x;
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:13,代码来源:main.cpp

示例13: timerGasBar

void timerGasBar(int value){
	// on posto
	if(player.getFlying() && !onPosto(player, arena.getPostoAbastecimento())){
		player.decGas();
	}

	// refuels
	if(onPosto(player, arena.getPostoAbastecimento())){
		player.setGas(player.getTempoDeVoo());
	}

	glutTimerFunc((1000),timerGasBar,0);
	glutPostRedisplay();
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:14,代码来源:main.cpp

示例14: display

void display(void){

	glClear (GL_COLOR_BUFFER_BIT);

		// arena and helicopter
		glPushMatrix();
			arena.drawArena(ARENAX, ARENAY);
		glPopMatrix();

		if(!checkDefeat(player, ARENAX/2.0,ARENAY/2.0)){
			// shots
			glPushMatrix();
				for(int i = 0 ; i < playerShots.size() ; i++) playerShots.at(i).draw();
				if(enemyShots.size() > 0){
					for(int i = 0 ; i < enemyShots.size() ; i++) enemyShots.at(i).draw();
				}
			glPopMatrix();

			glPushMatrix();
				player.draw();
			glPopMatrix();
			glPushMatrix();
				enemies.at(0).draw();
				enemies.at(1).draw();
				enemies.at(2).draw();
			glPopMatrix();
		}
	glEnd();
	glutSwapBuffers();
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:30,代码来源:main.cpp

示例15: mouse

void mouse(int button, int state, int x, int y){
	if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN){
		player.setFlying();
	}
	if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && player.getFlying()){
		// playerShots.push_back(Shot(player.getGunPosX(),
		// 							player.getGunPosY(),
		// 							player.getCurrentAngleGun(),
		// 							player.getAngle(),
		// 							player.getVelTiro(),
		// 							player.getAngleGun()));
		playerShots.push_back(Shot(player.getGunPosX(),
									player.getGunPosY(),
									player.getCurrentAngleGun(),
									player.getAngle(),
									player.getVelTiro(),
									player.getAngleGun()));
	}
}
开发者ID:ruanmartinelli,项目名称:cg-tc2,代码行数:19,代码来源:main.cpp


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