• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ shoot函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_msg

bool gun_actor::call( monster &z ) const
{
    Creature *target;
    if( z.friendly != 0 ) {
        // Attacking monsters, not the player!
        int boo_hoo;
        target = z.auto_find_hostile_target( range, boo_hoo );
        if( target == nullptr ) {
            // Couldn't find any targets!
            if( boo_hoo > 0 && g->u.sees( z ) ) {
                // because that stupid oaf was in the way!
                add_msg( m_warning, ngettext( "Pointed in your direction, the %s emits an IFF warning beep.",
                                              "Pointed in your direction, the %s emits %d annoyed sounding beeps.",
                                              boo_hoo ),
                         z.name().c_str(), boo_hoo );
            }
            return false;
        }

        shoot( z, *target );
        return true;
    }

    // Not friendly; hence, firing at the player too
    target = z.attack_target();
    if( target == nullptr || rl_dist( z.pos(), target->pos() ) > range ||
        !z.sees( *target ) ) {
        return false;
    }

    shoot( z, *target );
    return true;
}
开发者ID:Maeyanie,项目名称:Cataclysm-DDA,代码行数:33,代码来源:mattack_actors.cpp


示例2: shoot

void EnemyScout::doLogic(double delta)
{
    EnemyEntity::doLogic(delta);

    //shoot
    if(shotTicks > lastShot){
        lastShot = shotTicks;
        if(shotTicks % 50 == 45){
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
        }
        if(shotTicks % 50 == 46){
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
        }
        if(shotTicks % 50 == 47){
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
        }
        if(shotTicks % 50 == 48){
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
        }
        if(shotTicks % 50 == 49){
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
            shoot(200, targetPlayer,game->rand(-10,10)/10.0f);
        }
    }
}
开发者ID:bwarfield,项目名称:WarfieldBrian_CIS17C_48942,代码行数:29,代码来源:enemyscout.cpp


示例3: main

int main(int argc, char **argv)
{
	int x = MAX_X;
	int y = MAX_Y;
	int mines = MAX_MINES;
	// 	printf("%d %d %d\n\n", x, y, mines);
	if(argc==1) {

		struct Board *board = init_board(x, y, mines);
		init_AI(x, y, mines);
		int game=0;
		struct Point target;
		while (game >= 0) {
			print_board(board);
			printf("\n");
			print_AI_grid();
			printf("Target?");
			target = AI_get_target();
			printf("\nTargetting: %d %d\n", target.x, target.y);
			game = shoot(board, target.x, target.y);
			printf("Result: %d \n\n",game);
			AI_send_result(target.x, target.y, game);
		}
		printf("\n");
		if(game==-1)
			printf("LOST\n");
		else if(game==-2)
			printf("WON\n");
		free_board(board);
		free_AI();
	}
	else {
		int total=atoi(argv[1]);
		int i;
		int won=0;
		int last_percent=0, percent=0;
		for(i=0;i<total;i++) {
			struct Board *board = init_board(x, y, mines);
			init_AI(x, y, mines);
			int game=0;
			struct Point target;
			while (game >= 0) {
				target = AI_get_target();
				game = shoot(board, target.x, target.y);
				AI_send_result(target.x, target.y, game);
			}
			if(game==-2)
				won++;
			free_board(board);
			free_AI();
			percent = (int)((float)i/total*100);
			if(last_percent < percent) {
				printf("%d percent done, ratio: %f \n", percent, (float)won/(i+1));
				last_percent = percent;
			}
		}
		printf("Won %d out of %d\nRatio: %f \n", won, total, (float)won/total);
	}
	return 0;
}
开发者ID:abrochard,项目名称:minesweeperAI,代码行数:60,代码来源:main.c


示例4: if

VOID D1PlayerFighter::update(AEHashedTable<AEPlatform>* platformTable) {
    
    if (!(isKeyPressed(D1Key::KEY_LEFT) && isKeyPressed(D1Key::KEY_RIGHT))) {
        FLOAT xSpeed = 0.0f;
        if (isKeyPressed(D1Key::KEY_LEFT)) {
            xSpeed = -1.0f;
        }
        else if (isKeyPressed(D1Key::KEY_RIGHT)) {
            xSpeed = 1.0f;
        }
        else {
            xSpeed = 0.0f;
        }
        setVx(xSpeed);
    }
    FLOAT ySpeed = (isKeyPressed(D1Key::KEY_UP) ? -1.0f : 0.0f) + (isKeyPressed(D1Key::KEY_DOWN) ? 1.0f : 0.0f);
    setVy(ySpeed);
    
    attackTimer--;
    if (attackTimer == 25 || attackTimer == 15 || attackTimer == 5) {
        shoot(8.0f);
        shoot(-8.0f);
    }

    if (hpValue <= 0 && action < D1PlayerFighter::ACTION_KILLED) {
        changeAction(D1PlayerFighter::ACTION_KILLED);
        AESpriteAttachment* attachedShadow = attachmentTable->getItem(0);
        if (attachedShadow) attachedShadow->getSprite()->remove();
    }
    
    D1Sprite::update(platformTable);

}
开发者ID:mriiiron,项目名称:aero-engine-d3d,代码行数:33,代码来源:D1Sprite.cpp


示例5: fire

void fire(int n) {
	printf("fire\n\r\n\r");
	shoot(MAX_SPEED);
	delay(2000);
	load(CONVEYER_SPEED);
	delay(2000*n);
	load(0);
	shoot(0);
}
开发者ID:jmwiseman,项目名称:robottest,代码行数:9,代码来源:canned.c


示例6: autonomous

task autonomous()
{
	//Old Auton, Keep Until new one is Proven

	/*
	drive(127);
	wait1Msec(7000);//Test this
	motor[shooterL] = motor[shooterR] = 127;
	drive(0);
	wait1Msec(3000);
	motor[shooterL] = motor[shooterR] = 0;
	drive(0);
	*/
	//Adujust Times Below
	int speeder = 73;
	//Ball One

	shoot(speeder);
	wait1Msec(2000);
	intake(127);
	wait1Msec(400);
	intake(0);
	wait1Msec(750);

	//Ball Two

	shoot(speeder);
	wait1Msec(1000);
	intake(127);
	wait1Msec(650);
	intake(0);
	wait1Msec(750);

	//Ball Three

	shoot(speeder);
	wait1Msec(1000);
	intake(127);
	wait1Msec(650);
	intake(0);
	wait1Msec(750);

	//Ball Four

	shoot(speeder);
	wait1Msec(1000);
	intake(127);
	wait1Msec(650);
	intake(0);
	wait1Msec(750);

	//All Stop

	stopAll();

}
开发者ID:cloud5678,项目名称:cloud5678-2016,代码行数:56,代码来源:V3.5.c


示例7: forward

void forward(void)
{
	char b;
	// 600 IF F(1)>0 AND F(1)<7 THEN GOTO 660
	if (f[0]==1) {
		// 660 B=INT(RND(1)*3+1)
		// 670 SHOOT:PRINT SPC(5) TX$(B) :WAIT8*TI:SHOOT:CLS
		// 672 IF B=2 THEN ZAP:SHOOT:ZAP
		shoot();
		printf("     ");
		b = rand()%3;
		printf(message[b]);
		wait(360);
		shoot();
		cls();
		if (b==1) {
			zap();shoot();zap();
		}
	} else if(f[0]>1 && f[0]<7) {
		shoot();
		printf("Prenez la porte, mais pas comme ca !");
		wait(360);
		cls();
	} else {
		s_old = s;
		x_old = x;
		y_old = y;
		switch(s) {
			case 0:
				if(y>0)
					y--;
				break;
			case 1:
				if(x<XMAX)
					x++;
				break;
			case 2:
				if(y<XMAX)
					y++;
				break;
			case 3:
				if(x>0)
					x--;
				break;
			default:
				printf("erreur forward\n");
		}
	}
	// 330 CASE=C(X,Y)
	ca = c[x+y*XMAX];
	
	prep();
	drawLaby();
	manageCell();
}
开发者ID:hialmar,项目名称:tyrann3,代码行数:55,代码来源:laby.c


示例8: tPos

void TurretAIComponent::search() // Currently Only Shoots at the Player
{
	bool foundTarget = false;
	Position pos = curPosition_;
	Position tPos(0,0); // Target Position;

	pos = curPosition_;
	searchLine(pos, DIRECTION_UP, visionRange_, tPos, foundTarget);
	if (foundTarget == true)
	{
		targetPosition_ = tPos;
		shoot(DIRECTION_UP);
		targetFound_ = true;
		return;
	}

	pos = curPosition_;
	searchLine(pos, DIRECTION_DOWN, visionRange_, tPos, foundTarget);

	if (foundTarget == true)
	{
		targetPosition_ = tPos;
		shoot(DIRECTION_DOWN);
		targetFound_ = true;
		return;
	}

	pos = curPosition_;
	searchLine(pos, DIRECTION_LEFT, visionRange_, tPos, foundTarget);

	if (foundTarget == true)
	{
		targetPosition_ = tPos;
		shoot(DIRECTION_LEFT);
		targetFound_ = true;
		return;
	}

	pos = curPosition_;
	searchLine(pos, DIRECTION_RIGHT, visionRange_, tPos, foundTarget);

	if (foundTarget == true)
	{
		targetPosition_ = tPos;
		shoot(DIRECTION_RIGHT);
		targetFound_ = true;
		return;
	}
}
开发者ID:ZestyTheLion,项目名称:Mine-Mania,代码行数:49,代码来源:TurretAIComponent.cpp


示例9: switch

void Player::processKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode)
{
	switch (keyCode) 
	{
	case EventKeyboard::KeyCode::KEY_LEFT_ARROW:
	case EventKeyboard::KeyCode::KEY_A:
		move(Vec2(-Player::MAX_SPEED, 0), MOVE_LEFT_ACTION_TAG);
		break;
	case EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
	case EventKeyboard::KeyCode::KEY_D:
		move(Vec2(Player::MAX_SPEED, 0), MOVE_RIGHT_ACTION_TAG);
		break;
	case EventKeyboard::KeyCode::KEY_UP_ARROW:
	case EventKeyboard::KeyCode::KEY_W:
		move(Vec2(0, Player::MAX_SPEED), MOVE_UP_ACTION_TAG);
		break;
	case EventKeyboard::KeyCode::KEY_DOWN_ARROW:
	case EventKeyboard::KeyCode::KEY_S:
		move(Vec2(0, -Player::MAX_SPEED), MOVE_DOWN_ACTION_TAG);
		break;
	case EventKeyboard::KeyCode::KEY_SPACE:
		_isFiring = true;
		shoot();
		CCDirector::getInstance()->getScheduler()->schedule(schedule_selector(Player::shoot), this, FIRING_RATE, false);
		break;
	case EventKeyboard::KeyCode::KEY_P:
		if (_isFiring)
		{
			_isFiring = false;
			CCDirector::getInstance()->getScheduler()->unschedule(schedule_selector(Player::shoot), this);
		}
		this->stopAllActions();
		break;
	}
}
开发者ID:JPRodriguezExtremera,项目名称:Shooter2D,代码行数:35,代码来源:Player.cpp


示例10: switch

bool MainApplication::keyReleased( const OIS::KeyEvent& arg )
{
    switch (arg.key)
    {
        case OIS::KC_UP:
        case OIS::KC_W:
            mDirection.y = 0;
            break;

        case OIS::KC_DOWN:
        case OIS::KC_S:
            mDirection.y = 0;
            break;

        case OIS::KC_LEFT:
        case OIS::KC_A:
            mDirection.x = 0;
            break;

        case OIS::KC_RIGHT:
        case OIS::KC_D:
            mDirection.x = 0;
            break;

        case OIS::KC_SPACE:
            shoot();
            break;

        default:
            break;
        }
        return true;
}
开发者ID:dcastil1983,项目名称:ProjectFunny,代码行数:33,代码来源:MainApplication.cpp


示例11: switch

bool CannonField::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0:
        setAngle((int)static_QUType_int.get(_o+1));
        break;
    case 1:
        setForce((int)static_QUType_int.get(_o+1));
        break;
    case 2:
        shoot();
        break;
    case 3:
        newTarget();
        break;
    case 4:
        setGameOver();
        break;
    case 5:
        restartGame();
        break;
    case 6:
        moveShot();
        break;
    default:
        return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
开发者ID:satazor,项目名称:univ-aca-mips,代码行数:29,代码来源:moc_cannon.cpp


示例12: shoot

void Tower::attack(Object *obj)
{
    if(dynamic_cast<Card *>(obj) != NULL)
        dynamic_cast<Card *>(obj)->damaged(this->damage);

    shoot(obj->pos().x(), obj->pos().y());
}
开发者ID:atenagm1375,项目名称:clash-royale-simulation,代码行数:7,代码来源:Tower.cpp


示例13: atan

void BossGun::update(float frametime, int orientation, float x, float y, Input * input, LevelController * lc, float destX, float destY, bool shouldShoot) {
    playerX = x;
    playerY = y;
    adjacent = destX - x;
    opposite = destY - y;
    angle = atan((opposite / adjacent));
    spriteData.angle = angle;
    if (adjacent < 0) { // Facing back
        setX(x);
        setY(y + 80);
        flipHorizontal(true);
    } else {
        setX(x + 50);
        setY(y + 80);
        flipHorizontal(false);
    }
    angle = atan((destY - getY()) / (destX - getX()));
    // Fire bullet
    if (shouldShoot) { // Cause AI calls this
        Projectile* p = shoot(lc, frametime);
        if (p != nullptr)
            p->setOwner(Projectile::NPC);
    } else {
        cooldownCurrent -= frametime;
    }
    Entity::update(frametime);
}
开发者ID:Capeguy,项目名称:GPAssignment2,代码行数:27,代码来源:bossGun.cpp


示例14: take_action

int
take_action(void)
{
	/*
	 * Do the action specified by the player, either 'm'ove, 's'hoot
	 * or something exceptionally bizarre and strange!  Returns 1
	 * iff the player died during this turn, otherwise returns 0.
	 */
	switch (*answer) {
		case 'M':
		case 'm':			/* move */
			return(move_to(answer + 1));
		case 'S':
		case 's':			/* shoot */
			return(shoot(answer + 1));
		case 'Q':
		case 'q':
		case 'x':
			exit(0);
		case '\n':
			return(0);
		}
	if (random() % 15 == 1)
		(void)printf("Que pasa?\n");
	else
		(void)printf("I don't understand!\n");
	return(0);
}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:28,代码来源:wump.c


示例15: updateEntities

  int	updateEntities()
  {
    typename std::list<Type>::iterator	it;
    typename std::list<Type>::iterator	tmp;
    int	id;

    it = _list.begin();
    spawningEnemies();
    while (it != _list.end())
      {
	tmp = it;
	if (move(*it) == false)
	  tmp = _list.erase(it);
	else
	  {
	    shoot(*it);
	    collision(*it);
	    if ((*it)->checkDeath() == true)
	      {
		id = (*it)->getId();
		tmp = _list.erase(it);
		if ((*it)->getType() == SHIP)
		  return (id);
	      }
	  }
	if (tmp != it)
	  it = tmp;
	else
	  ++it;
      }
    return (-1);
  } 
开发者ID:lechevet,项目名称:rtype,代码行数:32,代码来源:EntityManager.hpp


示例16: world

void Enemy::step() {
	player_visible = !player->dead && world()->level->visible(shared_from_this(), std::static_pointer_cast<Entity>(player));
	player_distance = Game::distance(shared_from_this(), std::static_pointer_cast<Entity>(player));

	if(!attack) {
		scope();
		if(alert)
			hunt();
		else wander();
	}

	walking();
	worldCollision();

	dy += gravity;

	if(alert && frame==0) frame = 5;
	if(attack)
		shoot();

	processEntities();

	light->setPosition(sf::Vector2f(x,y));

	sprite.setPosition(round(x),round(y));
	sprite.setScale(facing_right?1.0:-1.0,1.0);
	sprite.setTextureRect(sf::IntRect(frame*24,0,24,24));
}
开发者ID:aeron005,项目名称:Diamond,代码行数:28,代码来源:Enemy.cpp


示例17: switch

void    Player::newInput(int const input) {
    switch (input) {
    case 97:
    case 100:
    case 115:
    case 119: {
        if (input == _direction) {
            _speed += calcSpeed(input, (15.0f - _speed) / 8.0f);
        } else if (_speed <= 0.5f) {
            switch (input) {
            case 119: _y -= 1.0f; break; // W (up)
            case 115: _y += 1.0f; break; // S (down)
            case 100: _x += 1.0f; break; // D (left)
            case 97:  _x -= 1.0f; break; // A
            }
            _speed = 0.0f;
        } else if ((input == 119 && _direction == 115)
                || (input == 115 && _direction == 119)
                || (input == 100 && _direction == 97)
                || (input == 97  && _direction == 100)) {
            _speed = 0.0f;
        } else if (_speed > 1.0f) {
            _speed -= calcSpeed(input, _speed - 1.0f) / 2.0f;
        }
        _direction = input;
        break;
    }
    default: shoot(); break;
    }
}
开发者ID:akabab,项目名称:cpp_rush00_space,代码行数:30,代码来源:Player.class.cpp


示例18: attack

void
attack(bprotocol *aProtocol,
       batstat *attackingSide, group *attackingGroup, int attackingShip,
       batstat *targetSide, group *targetGroup, int targetShip)
{

  if (shoot(attackingGroup, targetGroup)) {
    targetGroup->left--;
    (targetGroup->alive)[targetShip] = FALSE;
    if (targetGroup->type->weapons) {
      if ((targetGroup->canshoot)[targetShip]) {
        (targetGroup->canshoot)[targetShip] = FALSE;
        targetGroup->numberOfAttackersLeft--;
        targetSide->numberOfAttackersLeft--;
      }
    }
    addShot(aProtocol, attackingSide->who, attackingGroup->type,
            targetSide->who, targetGroup->type, 1);
    targetSide->numberOfTargets--;
    targetSide->who->masslost += typemass(targetGroup->type);
  }
  else {
    addShot(aProtocol, attackingSide->who, attackingGroup->type,
            targetSide->who, targetGroup->type, 0);
  }
}
开发者ID:scumola,项目名称:GalaxyNG,代码行数:26,代码来源:battle.c


示例19: shoot

void CharacterUpdaterPlayer::shoot(CCObjectCollideable *enemy)
{
    if( enemy != NULL )
    {
        shoot( enemy->getPosition(), enemy );
    }
}
开发者ID:playir,项目名称:PhoneWarsDemo,代码行数:7,代码来源:CharacterUpdaterPlayer.cpp


示例20: Entity

    Player::Player(World& world) : Entity(Configuration::Textures::Player,world)
                       ,ActionTarget(Configuration::player_inputs)
                       ,_is_moving(false)
                       ,_rotation(0)
    {
        bind(Configuration::PlayerInputs::Up,[this](const sf::Event&){
             _is_moving = true;
        });

        bind(Configuration::PlayerInputs::Left,[this](const sf::Event&){
             _rotation-= 1;
         });

        bind(Configuration::PlayerInputs::Right,[this](const sf::Event&){
             _rotation+= 1;
         });

        bind(Configuration::PlayerInputs::Shoot,[this](const sf::Event&){
             shoot();
         });

        bind(Configuration::PlayerInputs::Hyperspace,[this](const sf::Event&){
             goToHyperspace();
         });
    }
开发者ID:akashdeepk,项目名称:SFML-book,代码行数:25,代码来源:Player.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ short函数代码示例发布时间:2022-05-30
下一篇:
C++ shmget函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap