Ejemplo n.º 1
0
void GameWorld::checkCollisionVsEnemyShots(GameObject* go)
{
	Shot* shot;
	Rect goRect = go->getRectangle();

	for (int i = 0; i < m_gameObjectManager->getEnemyShotsInUse(); i++)
	{
		shot = m_gameObjectManager->getEnemyShot(i);

		// Check that the shot is on screen. If not, remove.
		shot->setActive(shot->collide(m_physicsComponent, m_cameraView));
		if (!shot->getActive())
		{
			m_gameObjectManager->removeEnemyShot(i);
			i--;
			continue;
		}

		if ( shot->collide(m_physicsComponent, goRect) )
		{
			go->Health -= shot->Damage;
			m_gameObjectManager->removeEnemyShot(i);
			i--;
			continue;
		}
	}
}
Ejemplo n.º 2
0
Shot*
Weapon::NetFireSecondary(SimObject* tgt, System* sub, DWORD objid)
{
    Shot* shot = 0;

    if (IsPrimary() || Game::Paused())
    return shot;

    if (active_barrel < 0 || active_barrel >= nbarrels)
    active_barrel = 0;

    target    = tgt;
    subtarget = sub;
    aim_time  = 0;

    shot = FireBarrel(active_barrel++);

    if (active_barrel >= nbarrels) {
        active_barrel = 0;
        refire += design->salvo_delay;
    }

    if (shot)
    shot->SetObjID(objid);

    if (target)
    Observe(target);

    return shot;
}
Ejemplo n.º 3
0
void GameWorld::checkCollisionVsPlayersShots(GameObject* go)
{
	Shot* shot;
	for (int j = 0; j < m_gameObjectManager->getPlayerShotsInUse(); j ++)
	{
		shot = m_gameObjectManager->getPlayerShot(j);

		// Check that the shot is on screen. If not, remove.
		shot->setActive(shot->collide(m_physicsComponent, m_cameraView));
		if (!shot->getActive())
		{
			m_gameObjectManager->removePlayerShot(j);
			j--;
			continue;
		}

		// check if shot hits enemy.
		if ( shot->collide(m_physicsComponent, go->getRectangle()))
		{
			go->Health -= shot->Damage;
			m_gameObjectManager->removePlayerShot(j);
			j--;
			continue;
		}
	}
}
Ejemplo n.º 4
0
bool simulateShot(fastfiz_msgs::SimulateShotRequest& req, fastfiz_msgs::SimulateShotResponse& res)
{
  TableState ts = msgToFiz(req.state);
  ShotParams shot = msgToFiz(req.shot);
  Shot* s = ts.executeShot(shot, false, false);

  typedef std::vector<Event*> V_Event;
  const V_Event& events = s->getEventList();
  V_Event::const_iterator it = events.begin();
  V_Event::const_iterator end = events.end();
  for (; it != end; ++it)
  {
    Event* e = *it;
    fastfiz_msgs::Event event;
    event.type = e->getType();
    event.ball1 = fizToMsg(e->getBall1());
    event.ball2 = fizToMsg(e->getBall2());
    event.string_rep = e->toString();

    res.events.push_back(event);
  }

  delete s;

  res.state = fizToMsg(ts);

  return true;
}
Ejemplo n.º 5
0
void GamePage::MoveShots(list<Shot> &shotsList)
{
	list<Shot>::iterator it = shotsList.begin();

	while (it != shotsList.end())
	{
		if (it->IsPossibleToMove())
		{
			it->Move(this->m_counter);
			it++;
		}
		else
		{
			if (g_pScreen->GetObjectAt(it->GetNextX(), it->GetNextY()) == OBJECT_TYPE_SHOT)
			{
				Shot *s = this->GetShotAt(it->GetNextX(), it->GetNextY());
				
				if (s->GetLastMove() == this->m_counter)
				{
					it++;
					continue;
				}
			}

			this->RemoveObject(it->GetNextX(), it->GetNextY());

			list<Shot>::iterator temp = it;
			it++;

			temp->Clear();
			shotsList.erase(temp);
		}
	}
}
Ejemplo n.º 6
0
void Game::sonicDeflectorEffect() {
  for ( unsigned int i = 0; i < racers->getNrRacers(); i++) {
    if ( racers->getRacer(i)->getShipType() == LIGHT_FIGHTER ) {
      Shot* nearestRocket = shots->getNearestRocket( racers->getRacer(i)->getPos() );
      // a rocket exists and it is in range of the sonic
      if ( nearestRocket != NULL &&
        (nearestRocket->getPos() - racers->getRacer(i)->getPos()).getLength() < 
        RACER_SONIC_ACTIVATION_DIST ) {
        // activate the correct sonic
        if (i == 0) {
          sonic1->setPos( racers->getRacer(i)->getPos(), nearestRocket->getPos() );
          nearestRocket->deflectedBySonicFromPlayer1 = true;
        } else {
          sonic2->setPos( racers->getRacer(i)->getPos(), nearestRocket->getPos() );
          nearestRocket->deflectedBySonicFromPlayer2 = true;
        }
      // no rocket is in sonic-range
      } else {
        // deactivate the sonic
        if (i == 0) {
          sonic1->setActive( false );
        } else {
          sonic2->setActive( false );
        }
      }
    }
  }
}
void
Dissolve::postComplete(Shot& initialShot, Shot& finalShot)
{
  initialShot.getCamera()._alpha = UNITY;
  finalShot.getCamera()._alpha = UNITY;
  _timeElapsed = ZERO;
  _timeStarted = ZERO;
}
Ejemplo n.º 8
0
void Troop::AllAct() {
  Shot *tmpsh;
  tmpsh->AllAct();
  int ctr=0;
  for(ctr=0; ctr<maxtr; ++ctr) if (trp[ctr] != NULL) {
    trp[ctr]->Act();
    }
  }
Ejemplo n.º 9
0
void Troop::DeleteAll() {
  Shot *tmpsh;
  tmpsh->DeleteAll();
  int ctr=0;
  for(ctr=0; ctr<maxtr; ++ctr) if (trp[ctr] != NULL) {
    delete trp[ctr];
    }
  }
void
NetGameClient::DoWepRelease(NetMsg* msg)
{
	if (!msg) return;

	NetWepRelease release;
	release.Unpack(msg->Data());

	NetPlayer* player = FindPlayerByObjID(release.GetObjID());
	if (player) {
		player->DoWepRelease(&release);
	}

	else {
		Ship* shooter = FindShipByObjID(release.GetObjID());
		if (shooter) {
			int   index = release.GetIndex();
			DWORD tgtid = release.GetTgtID();
			DWORD wepid = release.GetWepID();
			int   subid = release.GetSubtarget();
			bool  decoy = release.GetDecoy();
			bool  probe = release.GetProbe();

			Weapon* w = 0;

			if (decoy)        w = shooter->GetDecoy();
			else if (probe)   w = shooter->GetProbeLauncher();
			else              w = shooter->GetWeaponByIndex(index);

			if (w && !w->IsPrimary()) {
				SimObject*  target = FindShipByObjID(tgtid);
				System*     subtgt = 0;

				if (target) {
					if (subid >= 0) {
						Ship* tgt_ship = (Ship*) target;
						subtgt = tgt_ship->Systems().at(subid);
					}
				}
				else {
					target = FindShotByObjID(tgtid);
				}

				Shot* shot = w->NetFireSecondary(target, subtgt, wepid);

				if (shot && shot->IsDrone()) {
					if (probe)
					shooter->SetProbe((Drone*) shot);

					else if (decoy)
					shooter->AddActiveDecoy((Drone*) shot);
				}
			}
		}
	}
}
Ejemplo n.º 11
0
	void ManagerModel::AddShot(Vec2 startPosition) {
		Shot *shot = DBG_NEW Shot();
		shot->startPosition = startPosition;
		shot->OnInit(this);
		mEntities.push_back(shot);

		for (auto *view : mViews) {
			view->OnShotSpawned((Shot*)shot);
			view->PlayShotSoundEffect((Shot*)shot);
		}
	}
Ejemplo n.º 12
0
void Shooter::update() {
    //rand()
    if(mFrame %(mSpeed) == 0) {
        Shot* ms = new Shot();
        ms->setShotType(Shot::ShotType_Fireball);
        ms->setInitialVelocity(float2(0.f,mInitialVelocity[Shot::ShotType_Fireball].y));
        ms->setPosition(getPosition());
        mRoom->addEntity(ms);
    }

    mFrame++;
}
Ejemplo n.º 13
0
bool
NetPlayer::DoWepRelease(NetWepRelease* release)
{
	if (ship && release) {
		int   index = release->GetIndex();
		DWORD tgtid = release->GetTgtID();
		DWORD wepid = release->GetWepID();
		int   subid = release->GetSubtarget();
		bool  decoy = release->GetDecoy();
		bool  probe = release->GetProbe();

		Weapon* w = 0;

		if (decoy)        w = ship->GetDecoy();
		else if (probe)   w = ship->GetProbeLauncher();
		else              w = ship->GetWeaponByIndex(index);

		if (w && !w->IsPrimary()) {
			SimObject*  target = 0;
			System*     subtgt = 0;

			NetGame* net_game = NetGame::GetInstance();
			if (net_game) {
				target = net_game->FindShipByObjID(tgtid);

				if (target) {
					if (subid >= 0) {
						Ship* tgt_ship = (Ship*) target;
						subtgt = tgt_ship->Systems().at(subid);
					}
				}
				else {
					target = net_game->FindShotByObjID(tgtid);
				}
			}

			Shot* shot = w->NetFireSecondary(target, subtgt, wepid);

			if (shot && shot->IsDrone()) {
				if (probe)
				ship->SetProbe((Drone*) shot);

				else if (decoy)
				ship->AddActiveDecoy((Drone*) shot);
			}

			return true;
		}
	}

	return false;
}
void
NetGameClient::DoObjDamage(NetMsg* msg)
{
	if (!msg) return;

	NetObjDamage obj_damage;
	obj_damage.Unpack(msg->Data());

	Ship* ship = FindShipByObjID(obj_damage.GetObjID());
	if (ship) {
		Sim*        sim         = Sim::GetSim();
		Shot*       shot        = FindShotByObjID(obj_damage.GetShotID());
		const Ship* owner       = 0;
		const char* owner_name  = "[NET]";

		ship->InflictNetDamage(obj_damage.GetDamage(), shot);

		if (shot && sim) {
			if (shot->Owner()) {
				owner       = shot->Owner();
				owner_name  = owner->Name();
			}

			if (shot->IsMissile()) {
				SimRegion*  region = ship->GetRegion();
				float       scale  = ship->Design()->explosion_scale;

				if (scale <= 0)
				scale = ship->Design()->scale;

				if (owner) {
					const ShipDesign* owner_design = owner->Design();
					if (owner_design && owner_design->scale < scale)
					scale = (float) owner_design->scale;
				}

				sim->CreateExplosion(shot->Location(), Point(), Explosion::SHOT_BLAST, 20.0f * scale, scale, region);
			}

			if (!shot->IsBeam()) {
				if (owner) {
					ShipStats* stats = ShipStats::Find(owner_name);

					if (stats) {
						if (shot->IsPrimary())
						stats->AddGunHit();
						else if (shot->Damage() > 0)
						stats->AddMissileHit();
					}
				}

				shot->Destroy();
			}
		}
	}
}
void
NetGameClient::DoWepDestroy(NetMsg* msg)
{
	if (!msg) return;

	NetWepDestroy destroy;
	destroy.Unpack(msg->Data());

	Shot* shot = FindShotByObjID(destroy.GetObjID());
	if (shot) {
		if (shot->IsBeam())
		::Print("NetGameClient::DoWepDestroy shot '%s'\n", shot->Name());

		shot->Destroy();
	}
}
Ejemplo n.º 16
0
vcg::Point2f Parameters::pixelDiff(Shot &test, vcg::Point3f p)
{
  vcg::Point2f before = reference.Project(p)*rx;
  if(before[0] < 0 || before[0] > reference.Intrinsics.ViewportPx[0] || before[1] < 0 || before[1] > reference.Intrinsics.ViewportPx[1])
	  return vcg::Point2f(0, 0);
  vcg::Point2f after = test.Project(p)*rx;
  return (after - before);
}
Ejemplo n.º 17
0
void Demo::render( base::ContextPtr context )
{
	if( m_shots.empty() )
		return;


	float time = context->time();

	// find current shot
	Shot *shot = &m_shots[0];
	for( int i=0, numShots = (int)m_shots.size();i<numShots;++i )
	{
		Shot &s = m_shots[i];
		if( ( time > s.start)&&( time < s.end) )
		{
			shot = &s;
			break;
		}
	}

	//std::cout << shot->scene->getName() << std::endl;
	//std::cout << time << std::endl;
	

	float localTime = shot->getLocalTime(time);
	
	// update camera from shot camera
	if( shot->camera )
	{
		m_camera->m_transform = shot->camera->xform.eval(localTime);
		m_camera->m_fov = math::degToRad(shot->camera->fov);
		m_camera->update();
	}
	//context->setCamera( m_camera );

	m_renderFBO->begin();
	shot->scene->render(context);
	m_renderFBO->end();
	
	m_post->render();



	// debug
	//m_visualiser->render();
}
Ejemplo n.º 18
0
	static void WPN_Boom(Shot& shot, std::vector<Player>& players, Player* playerThatWasHit, SpriteList& spriteList, FireList& fireList)
	{
        std::vector<Player*> killedPlayers;
        std::vector<Player*> hittedPlayers;

		Player& author = shot.getPlayer();

		Float32 range = shot.getExplosionRange();
		Float32 power = shot.getExplosionPower();

		const Vector shotCentre = shot.getCentre();
		bool shit = shot.getWeapon().shit;

		if (!shit)
		{
			fireList.check(shotCentre, range, spriteList);
		}

		for (Player& player : players)
		{
			bool directHit = (playerThatWasHit != nullptr && player.is(*playerThatWasHit));
			Vector playerCentre = player.getCentre();
			Float32 dist = directHit ? 0 : (playerCentre - shotCentre).length();

			if (directHit || dist < range)
			{
                hittedPlayers.push_back(&player);
				if (shit)
				{
					player.useTemporarySkin(*brownSkin);
				}
				else
				{
					if (player.hitByShot(directHit ? power : ((range - dist) * power) / range, shot, directHit))
					{
						killedPlayers.push_back(&player);
					}
				}
			}
		}

        author.processHits(shot, hittedPlayers);
        author.processKills(shot, killedPlayers);
	}
Ejemplo n.º 19
0
	static Hit WPN_ShotPlayerCollision(Shot& shot, std::vector<Player>& players)
	{
		const Rectangle shotBox = shot.getCollisionRect();

		for (Player& player : players)
		{
			if (!player.isInGame() || player.getBonus() == D6_BONUS_INVIS || player.is(shot.getPlayer()))
			{
				continue;
			}

			if (Collision::rectangles(player.getCollisionRect(), shotBox))
			{
				return {true, &player};
			}
		}

		return { false, nullptr };
	}
Ejemplo n.º 20
0
void
Dissolve::increment(Shot& initialShot, Shot& finalShot)
{
  //  Microseconds(&_tick);
  //  _timeCurrent = (float) UnsignedWideToUInt64(_tick);

  gettimeofday(&_tick, NULL);    

  double doubleTime = _tick.tv_usec;
  doubleTime += _tick.tv_sec * 1000000;
  _timeCurrent = (float) doubleTime;

  _timeElapsed = _timeCurrent - _timeStarted;
  float fraction = _timeElapsed / _timePeriod;

  if (fraction > UNITY) {
    _inProgress = false;
  } else {
    initialShot.getCamera()._alpha = UNITY - fraction;
    finalShot.getCamera()._alpha = fraction;
  }
}
Ejemplo n.º 21
0
Shot::Shot(int id, float px, float py, b2Vec2 force, int limit)
{
    name = "shot";
    type = id;

    this->getBodyFixture()->filter.maskBits = FilterShots | FilterWalls | FilterNormal | FilterEnemy | FilterObjects;
    this->getBodyFixture()->filter.categoryBits= FilterShots;

    if(id == 1)
    {
        this->setTexture(TextureManager::TextureControl.get("boulder_8"));
        this->getSprite()->setOrigin(4,4);
        this->m_bodyCircleShape.m_radius = 4/pixelsPerMeter;

        this->getBodyDef()->position.Set(
                    px,
                    py
                    );
        this->getBodyDef()->type = b2_dynamicBody;
        this->getBodyFixture()->friction = 0.5f;
        this->getBodyFixture()->restitution = 0.4f;
        this->getBodyFixture()->density = 2.f;

        this->m_bodyDef.fixedRotation = false;
        this->m_bodyDef.angularDamping = 2.5f;

        Engine::bodylist.push_back(this);
    }
    else if(id == 2)
    {
        this->setTexture(TextureManager::TextureControl.get("boulder_8"));
        this->getSprite()->setOrigin(4,4);
        this->m_bodyCircleShape.m_radius = 4/pixelsPerMeter;

        this->getBodyDef()->position.Set(
                    px-2,
                    0
                    );
        this->getBodyDef()->type = b2_dynamicBody;
        this->getBodyFixture()->friction = 0.5f;
        this->getBodyFixture()->restitution = 0.4f;
        this->getBodyFixture()->density = 2.f;
        this->m_bodyDef.fixedRotation = false;
        this->m_bodyDef.angularDamping = 2.5f;

        if(limit < 8){
            Shot* shot = new Shot(2, px, py, force, limit+1);
            shot->getBodyFixture()->filter.groupIndex = 1;
            shot->createBody(*Engine::world, true);

            force.x *= shot->getBody()->GetMass();
            force.y *= shot->getBody()->GetMass();
            shot->getBody()->ApplyLinearImpulse(force ,shot->getBody()->GetWorldCenter(),true);
        }

        Engine::bodylist.push_back(this);
    }
}
Ejemplo n.º 22
0
double Solver::calculateError2( Shot &shot){
	//E' una pezza, andrebbe meglio pensato. Va a beccare direttamente le strutture dati PointCorrespondence di base.
	//align già è sicuramente settato perchè lo chiami da optimize (poi dovrai distinguere le due cose, p.e. fare un optimize2)
	QList<PointCorrespondence*> *correspList = align->correspList;
	double error = 0;
	int count=0;

    for( int i=0; i<correspList->count(); i++){
        PointCorrespondence *corr = correspList->at(i);
        PointOnLayer currentPointOnLayer1= corr->getPointAt(0);
        PointOnLayer currentPointOnLayer2= corr->getPointAt(1);
        PointType type1 = currentPointOnLayer1.getType();
        vcg::Point3f currentPoint1(currentPointOnLayer1.pX, currentPointOnLayer1.pY,currentPointOnLayer1.pZ );
        vcg::Point3f currentPoint2(currentPointOnLayer2.pX, currentPointOnLayer2.pY,currentPointOnLayer2.pZ );
        vcg::Point2f p2adj;
		vcg::Point2f p1proj;
        if(type1==_3D_POINT){
            //Adjust 2D point
			p2adj = vcg::Point2f(((currentPoint2.X()/align->imageRatio) +1)/2.0 * shot.Intrinsics.CenterPx.X()*2.0,((currentPoint2.Y())+1)/2.0 * shot.Intrinsics.CenterPx.Y()*2.0);
			//Project 3D point
			p1proj = shot.Project(currentPoint1);
        }
        else{
           //Adjust 2D point
			p2adj = vcg::Point2f(((currentPoint1.X()/align->imageRatio) +1)/2.0 * shot.Intrinsics.CenterPx.X()*2.0,((currentPoint1.Y())+1)/2.0 * shot.Intrinsics.CenterPx.Y()*2.0);
			//Project 3D point
			p1proj = shot.Project(currentPoint2);
        }

		float dist = vcg::Distance<float>(p1proj,p2adj);
		error += dist;
		count++;
	}

	//Normalize error
	return error /= count;

}
Ejemplo n.º 23
0
void PlayerEntity::atira()
{
    //Arrow
    float powerX = shot_power*cos(angle*M_PI/180.f);
    float powerY = shot_power*sin(angle*M_PI/180.f);


    if(selectedShot <= 2) {
        Shot* shot = new Shot(selectedShot,
                              (this->m_animation.getSprite().getPosition().x)/pixelsPerMeter,
                              (this->m_animation.getSprite().getPosition().y)/pixelsPerMeter,
                              b2Vec2( powerX/pixelsPerMeter,
                                      powerY/pixelsPerMeter) );
        shot->createBody(*Engine::world, true);

        shot->getBody()->ApplyLinearImpulse(b2Vec2( shot->getBody()->GetMass()*powerX/pixelsPerMeter,
                                                    shot->getBody()->GetMass()*powerY/pixelsPerMeter  ),shot->getBody()->GetWorldCenter(),true);

    }else
    {
        ShotArrow* shot = new ShotArrow(selectedShot,
                              (this->m_animation.getSprite().getPosition().x)/pixelsPerMeter,
                              (this->m_animation.getSprite().getPosition().y)/pixelsPerMeter,
                              b2Vec2( powerX/pixelsPerMeter,
                                      powerY/pixelsPerMeter) );
        shot->createBody(*Engine::world);
        shot->getBody()->SetAngularDamping( 3 );

        shot->getBody()->ApplyLinearImpulse(b2Vec2( shot->getBody()->GetMass()*powerX/pixelsPerMeter,
                                                    shot->getBody()->GetMass()*powerY/pixelsPerMeter  ),shot->getBody()->GetWorldCenter(),true);
    }
    //Sfx
    if(selectedShot == 2)
        Engine::EngineControl.playSfx("data/music/sfx/shot1.wav");
    else
        Engine::EngineControl.playSfx("data/music/sfx/shot3.wav");
}
Ejemplo n.º 24
0
	static Hit WPN_ShotWallCollision(Shot& shot, const Level& level)
	{
		const Rectangle box = shot.getCollisionRect();
		Int32 up = Int32(box.right.y);
		Int32 down = Int32(box.left.y);
		Int32 left = Int32(box.left.x);
		Int32 right = Int32(box.right.x);

		bool hitsWall = level.isWall(left, up, true) ||
			level.isWall(left, down, true) ||
			level.isWall(right, up, true) ||
			level.isWall(right, down, true);

		return { hitsWall, nullptr };
	}
Ejemplo n.º 25
0
void BulletManager::fireShot(Message* msg)
{
    if(MessageAny<bulletDesc>* message = message_cast<bulletDesc>(msg))
    {
        bulletDesc dsc = message_cast<bulletDesc>(msg)->data;
        Shot* sht = 0;
        for(unsigned int i=0; i<mShotsCache.size(); ++i)
        {
            if(mShotsCache[i]->getBulletType()==dsc.type)
            {
                sht = mShotsCache[i];
                sht->reactivate(dsc.pos,dsc.dir,dsc.speed,dsc.ori);
                mShotsCache.erase(mShotsCache.begin()+i);
                break;
            }
        }
        if(!sht)
        {
            sht = new Shot(mEngine,"Bullets","Bullet"+StringUtils::toString(nrB),dsc.pos,dsc.dir,dsc.ori,dsc.speed,dsc.type);
            ++nrB;
        }
        mShots.push_back(sht);
    }
}
Ejemplo n.º 26
0
void Hero::fireWeapon(){
	if(mWeaponSelected == Weapon_None){
		return;
	}
	Shot* ms = new Shot();
	if (mWeaponSelected == Weapon_Gun){
		ms->setShotType(Shot::ShotType_Bullet);
		Sound::playSample("data/sounds/shoot.wav");
	} else if (mWeaponSelected == Weapon_Gravity_Grenade){
		ms->setShotType(Shot::ShotType_GravityGrenade);
		Sound::playSample("data/sounds/throwgrenade.wav");
	}
	ms->setPosition(getPosition());
	ms->setDirection(getFacingDirection());
	ms->setInitialVelocity(float2(ms->getInitialVelocity().x, ms->getInitialVelocity().y * getGravityDirection()));
	mRoom->addEntity(ms);

}
Ejemplo n.º 27
0
Shot ShotDialog::shotSetup()
{
	RecordList rl;
	Shot temp;
	AssetTemplate at = mTemplateCombo->assetTemplate();
	if( at.isRecord() )
		temp = Element::createFromTemplate( at, rl );
	else
		temp = AssetType::recordByName( "Shot" ).construct();
	ElementList el(rl);
	el.setProjects( mElement.project() );
	el.commit();
	LOG_5( "Shot's assettype is: " + temp.assetType().name() );
	temp.setFrameStart( mFrameStartSpin->value() );
	temp.setFrameEnd( mFrameEndSpin->value() );
	temp.setName( mShotName->text() );
	temp.setParent( mElement );
	temp.setProject( mElement.project() );
	temp.setElementStatus( ElementStatus::recordByName( "New" ) );
	temp.setElementType( Shot::type() );
	return temp;
}
Ejemplo n.º 28
0
void ShotDialog::updateResult()
{
	QString resText("Result: ");
	resText += mShotName->text();
	Shot s;
	s.setShotNumber( mShotStart->text().toDouble() );
	s.setElementType( Shot::type() );
	resText += s.displayNumber();
	if( mShotStart->text() != mShotEnd->text() && !mShotStart->text().contains( "." ) ){
		s.setShotNumber( mShotEnd->text().toDouble() );
		resText += " to " + mShotName->text() + s.displayNumber();
	}
	mStatusLabel->setText( resText );
}
Ejemplo n.º 29
0
        void buttonDown(Gosu::Button btn) 
        { 
		  if (onStartScreen)
		  {
			  onStartScreen = false;
			  level = 1;
			  player.resetPlayer();
			  loadLevel(level, true);
		  }
		  else if (player.isDead())
		  {
			  onStartScreen = true;
			  level = 0;
			  round = 1;
			  loadLevel(level, true);
		  }
		  else
		  {			
			  if (btn == Gosu::kbEscape)
				close();
			  else if ((btn == Gosu::kbReturn || btn == Gosu::kbEnter) && !transitioning)
			  {
				  if (paused)
					paused = false;
				  else
					paused = true;
			  }

			  if (!paused && !shot.active() && !player.isOnFire())
			  {
				  if (btn == Gosu::kbSpace && player.isStandingStill())
				  {
					  player.shoot(shot, enemies, environment);
				  }
				  else if (btn == Gosu::kbW)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
				  }
				  else if (btn == Gosu::kbS)
				  {
					  player.moveGunDown();
					  player.moveGunDown();
				  }
				  else if (btn == Gosu::kbA)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
					  player.moveGunDown();
					  player.turnLeft();
				  }
				  else if (btn == Gosu::kbD)
				  {
					  player.moveGunUp();
					  player.moveGunUp();
					  player.moveGunDown();
					  player.turnRight();
				  }
			  }
		  }
        }
Ejemplo n.º 30
0
        void draw() {
          if (transitioning || onStartScreen) {
            backgroundImage->draw(0, 0, zBackground);
            Gosu::Image& ammoBarImage = *ammoBarAnim.at(20 - player.getAmmo());
            ammoBarImage.draw(240, 92, zUI);

            Gosu::Image& healthBarImage = *healthBarAnim.at(10 - player.getHealth());
            healthBarImage.draw(240, 3, zUI);

            scoreLabelImage->draw(5, 215, zUI);
            Gosu::Image& scoreDigit3Image = *numbersAnim.at(player.getScore() / 1000 % 10);
            scoreDigit3Image.draw(68, 215, zUI);
            Gosu::Image& scoreDigit2Image = *numbersAnim.at(player.getScore() / 100 % 10);
            scoreDigit2Image.draw(80, 215, zUI);
            Gosu::Image& scoreDigit1Image = *numbersAnim.at(player.getScore() / 10 % 10);
            scoreDigit1Image.draw(92, 215, zUI);
            Gosu::Image& scoreDigit0Image = *numbersAnim.at(player.getScore() % 10);
            scoreDigit0Image.draw(104, 215, zUI);

			for (std::list<Item>::const_iterator i = items.begin(); i != items.end(); ++i)
            {
              i->draw();
            }
          }
          else {
            player.draw();
            shot.draw();
            for (std::list<Enemy>::const_iterator i = enemies.begin(); i != enemies.end(); ++i)
            {
              i->draw();
            }
            for (std::list<Item>::const_iterator i = items.begin(); i != items.end(); ++i)
            {
              i->draw();
            }

			int spotlightRadius;
			if (round == 1)
				spotlightRadius = 50;
			else if (round == 2)
				spotlightRadius = 42;
			else if (round == 3)
				spotlightRadius = 33;
			else
				spotlightRadius = 25;
            spotlight.draw(player, spotlightRadius);
            backgroundImage->draw(0, 0, zBackground);

            Gosu::Image& ammoBarImage = *ammoBarAnim.at(20 - player.getAmmo());
            ammoBarImage.draw(240, 92, zUI);

            Gosu::Image& healthBarImage = *healthBarAnim.at(10 - player.getHealth());
            healthBarImage.draw(240, 3, zUI);

            scoreLabelImage->draw(5, 215, zUI);
            Gosu::Image& scoreDigit3Image = *numbersAnim.at(player.getScore() / 1000 % 10);
            scoreDigit3Image.draw(68, 215, zUI);
            Gosu::Image& scoreDigit2Image = *numbersAnim.at(player.getScore() / 100 % 10);
            scoreDigit2Image.draw(80, 215, zUI);
            Gosu::Image& scoreDigit1Image = *numbersAnim.at(player.getScore() / 10 % 10);
            scoreDigit1Image.draw(92, 215, zUI);
            Gosu::Image& scoreDigit0Image = *numbersAnim.at(player.getScore() % 10);
            scoreDigit0Image.draw(104, 215, zUI);
          }
        }