コード例 #1
0
ファイル: Player.cpp プロジェクト: heywire534/engine_Develop
void Player::updateMouseMove( OIS::Mouse* mouse ) 
{
	if(mouse->getMouseState().buttonDown(OIS::MB_Left)) 
	{
		if( isMissileEnabled() && numOfBullet > 0 && isReloadEnabled() ) 
		{
			if ( mAnimStates->getTimePosition() < 3.0f )
			{
				mAnimStates->setLoop(true);
				mAnimStates->setTimePosition(0);
			}

			numOfBullet--;
			mMissile.insert(fireMissile());

			if ( effectChannel[0] == INVALID_SOUND_CHANNEL )
				soundMgr->PlaySound(fireEffect, mSceneMgr->getRootSceneNode(), &effectChannel[0]);
			else 
				soundMgr->StopSound(&effectChannel[0]);

			hitscan();
		}
	}
	else
		mAnimStates->setLoop(false);

	mYawNode->yaw( Degree( -0.06f * mouse->getMouseState().X.rel ) );
	mPitchNode->pitch( Degree( -0.06f * mouse->getMouseState().Y.rel ) );
}
コード例 #2
0
ファイル: column.cpp プロジェクト: nlemon/AirWolf
Column::Column(int xval, XInfo& info){

  x = xval;

  //randomly generate the height of the column
  numberOfBlocks = rand() % 10;
  blockey = new Block(info.windowWidth / 15, info.windowHeight / 15);
  y = info.windowHeight - (blockey->height * numberOfBlocks);
  width = blockey->width;
  height = blockey->height;

  missiles = NULL;
  orbo = NULL;
  killTrophy = NULL;

  int isMissile = rand() % 10;
  int isHealth = rand() % 200;

  //there is a one in three chance of generating a missile silo
  if(isMissile < 4){

    missiles = new std::list<Missile*>();
    fireMissile();

  }

  if(isHealth < 10){

    orbo = new HealthOrb(x + (blockey->width / 3), y - (blockey->height * 5), blockey->width / 3, blockey->height / 2);

  }
 
}
コード例 #3
0
ファイル: column.cpp プロジェクト: nlemon/AirWolf
//COLUMN METHODS
void Column::paint(XInfo& info){

  int currentHeight = y;
  if(missiles != NULL && !(missiles->empty())){

    //check to see if it's time to fire off a missile
    if(((y - blockey->height) - missiles->back()->getY()) > (info.missileFrequency * blockey->height)){

      fireMissile();

    }

    std::list<Missile*>::iterator missile = missiles->begin();

    //silo and silo tip positions
    int siloX = x + (blockey->width / 3);
    int siloY = y - (3 * (blockey->height / 4));

    int siloTipX = siloX + (blockey->width / 9);
    int siloTipY = y - blockey->height;

    //loop through and draw all missiles currently deployed
    for(int i = 0; i < missiles->size(); i++, missile++){

      (*missile)->paint(info);

    }

    //draw the silo
    XDrawRectangle(info.display, info.pixie, info.gc, siloX, siloY, blockey->width / 3, 3 * (blockey->height / 4));
    XDrawRectangle(info.display, info.pixie, info.gc, siloTipX, siloTipY, blockey->width / 9, blockey->height / 4);
 

  }

  //draw the column
  for(int i = 0; i < numberOfBlocks; i++){

    XDrawRectangle(info.display, info.pixie, info.gc, x, currentHeight, blockey->width, blockey->height);
    currentHeight += blockey->height;

  }

  if(orbo != NULL){

    //draw the orb
    orbo->paint(info);

  }

  if(killTrophy != NULL){

    killTrophy->paint(info);

  }

}
コード例 #4
0
ファイル: Game.cpp プロジェクト: Finbass/Spaceship-Game
void Game::allLocking() {
	if (mouse.LeftIsPressed() && !mouseClicked) {
		//if (noOfLockedOn > 0) 
		if (playerShip.missileAmmunition > 0) fireMissile(true);
		mouseClicked = true;
	}

	if (mouse.RightIsPressed() && playerShip.missileAmmunition > 0) { //for now or maybe forever? Ok Ive decided forever, its better.
		if (!currentlyLocking && specificTarget == NULL && noOfLockedOn < playerShip.missileAmmunition) {
			findLockOn();
		} 
		else if (currentlyLocking && specificTarget) createLockOn();
	}
	else {
		if (specificTarget) { //coz accessing specificTarget->lockingOn when its null is impossible
			specificTarget->lockingOn = false;
			specificTarget->frame = 0;
			specificTarget->startTime = GetTickCount();
			specificTarget = NULL;
		}
		specificTarget = NULL;
		currentlyLocking = false;
	}

	if (!mouse.LeftIsPressed()) mouseClicked = false;

	for (int i = 0; i < pShipTargets.size(); i++) {
		if ((GetTickCount() - pShipTargets[i].startTime) > pShipTargets[i].lockOnDelay && !pShipTargets[i].lockedOn) {
			if (pShipTargets[i].ship == NULL) pShipTargets.erase(pShipTargets.begin() + i);
			pShipTargets[i].startTime = GetTickCount();
			pShipTargets[i].frame++;
			//pShipTargets[i].lockOnDelay make this a variable so slower for first 8. different speed for 8-37
			//pShipTargets[i].frame = rand() % 8; so they all dont rotate the same; //doesnt matter anymore since it only shows sometimes.
			if (/*!currentlyLocking &&*/ //hmmm keep this? Want other ships to have things over them while locking onto another?
				Distance(mouse.GetMouseX(), mouse.GetMouseY(), pShipTargets[i].ship->x, pShipTargets[i].ship->y) < 100) {
				pShipTargets[i].inMouseRange = true;
				
			}
			else pShipTargets[i].inMouseRange = false;

			if (pShipTargets[i].frame >= 8 && !pShipTargets[i].lockingOn) pShipTargets[i].frame = 0;
			if (pShipTargets[i].frame >= 38 && pShipTargets[i].lockingOn) {
				noOfLockedOn++;
				pShipTargets[i].lockedOn = true;
				pShipTargets[i].lockingOn = false;
				pShipTargets[i].frame = 39;
				currentlyLocking = false;
				createMissile(true, pShipTargets[i].ship);
				specificTarget = NULL;
			}
		}
	}
}
コード例 #5
0
ファイル: being.cpp プロジェクト: Ablu/mana
void Being::handleAttack(Being *victim, int damage, int attackId)
{
    // Monsters, NPCs and remote players handle the first attack (id="1")
    // per default.
    // TODO: Fix this for Manaserv by sending the attack id.
    // TODO: Add attack type handling, see Attack struct and AttackType
    // and make use of it by grouping attacks per attack type and add random
    // attack use on tA, based on normal and critical attack types.
    if (this != local_player)
        setAction(Being::ATTACK, attackId);

    if (victim)
        lookAt(victim->getPosition());

    if (getType() == PLAYER && victim && mEquippedWeapon)
        fireMissile(victim, mEquippedWeapon->getMissileParticleFile());
    else
        fireMissile(victim,
                    mInfo->getAttack(attackId)->mMissileParticleFilename);

    sound.playSfx(mInfo->getSound((damage > 0) ?
                  SOUND_EVENT_HIT : SOUND_EVENT_MISS),
                  getPixelX(), getPixelY());
}
コード例 #6
0
ファイル: player.c プロジェクト: akien-mga/tbftss
static void preFireMissile(void)
{
	if (player->missiles && player->target)
	{
		if (getDistance(player->x, player->y, player->target->x, player->target->y) <= SCREEN_WIDTH)
		{
			fireMissile(player);
		}
		else
		{
			playSound(SND_GUI_DENIED);
			
			addHudMessage(colors.white, _("Target not in range"));
		}
	}
	else if (!player->missiles)
	{
		addHudMessage(colors.white, _("Out of missiles"));
		
		playSound(SND_NO_MISSILES);
	}
}
コード例 #7
0
void Game::handleInput(sf::Event* event)
{
	switch (event->type)
	{
	case sf::Event::MouseButtonPressed:
		if (event->mouseButton.button == sf::Mouse::Left)
		{
			if (!isGameOver)
			{
				fireMissile(getScaledMouseCoords(window, settings));
			}
		}
		break;
	case sf::Event::KeyReleased:
		if (event->key.code == sf::Keyboard::Escape)
		{
			score.updateHighScore();
			currentState = State::MENU;
		}
		break;
	default:
		break;
	}
}