示例#1
0
HoldLine::HoldLine(QWidget *parent) : QWidget(parent){
  XLOC = 36;
  level = 0;
  points = 0;
  gameOver = false;
  gameWon = false;
  paused = false;
  gameStarted = false;
  moving = false;
  prot = new Protagonist();
  quiver = new Quiver();
  trapBag = new TrapBag();
  protect = new Protect();
  protectItem = new ProtectItem();

  ammoList.push_back(quiver);
  ammoList.push_back(trapBag);

  
  MAXENEMIES = 10;
  createBullets(3);
  createArrows(8);
  createTraps(5);
  createTrees(4);

}
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type)
, mFireCommand()
, mMissileCommand()
, mFireCountdown(sf::Time::Zero)
, mIsFiring(false)
, mIsLaunchingMissile(false)
, mShowExplosion(true)
, mSpawnedPickup(false)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.get(Textures::Explosion))
, mFireRateLevel(1)
, mSpreadLevel(1)
, mMissileAmmo(2)
, mDropPickupCommand()
, mTravelledDistance(0.f)
, mDirectionIndex(0)
, mMissileDisplay(nullptr)
{
	mExplosion.setFrameSize(sf::Vector2i(256, 256));
	mExplosion.setNumFrames(16);
	mExplosion.setDuration(sf::seconds(1));

	centerOrigin(mSprite);
	centerOrigin(mExplosion);

	mFireCommand.category = Category::SceneAirLayer;
	mFireCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createBullets(node, textures);
	};

	mMissileCommand.category = Category::SceneAirLayer;
	mMissileCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
	};

	mDropPickupCommand.category = Category::SceneAirLayer;
	mDropPickupCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createPickup(node, textures);
	};

	std::unique_ptr<TextNode> healthDisplay(new TextNode(fonts, ""));
	mHealthDisplay = healthDisplay.get();
	attachChild(std::move(healthDisplay));

	if (getCategory() == Category::PlayerAircraft)
	{
		std::unique_ptr<TextNode> missileDisplay(new TextNode(fonts, ""));
		missileDisplay->setPosition(0, 70);
		mMissileDisplay = missileDisplay.get();
		attachChild(std::move(missileDisplay));
	}

	updateTexts();
}
示例#3
0
Ship::Ship(Type type, const TextureHolder& textures)
	: Entity(Table[type].hitpoints)
	, _type(type)
	, _sprite(textures.get(Table[type].texture))
    , _fireCommand()
    , _fireCountdown(sf::Time::Zero)
    , _isFiring(false)
    , _isMarkedForRemoval(false)
    , _travelledDistance(0.f)
    , _directionIndex(0)
    , _invisTimer()
    , _godmode(0)
{
	centerOrigin(_sprite);
    
    _fireCommand.category = Category::Scene;
	_fireCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createBullets(node, textures);
	};
}