예제 #1
0
파일: Bee.cpp 프로젝트: TylerSandman/marvin
Bee::Bee(TextureManager &textureManager, b2Body *enemyBody, float moveVelocity, std::vector<sf::Vector2f> waypoints, float steering) :
    Entity(enemyBody),
    mMoveVelocity(moveVelocity),
    mSteering(steering),
    mSeeking(false) {

    sf::Texture &spriteSheet = textureManager.get(TextureID::EnemiesSpriteSheet);
    Animation animation;
    animation.setSpriteSheet(spriteSheet);
    animation.addFrame(sf::IntRect(315, 353, 56, 48));
    animation.addFrame(sf::IntRect(140, 23, 61, 42));
    mAnimation = animation;
    mSprite = AnimatedSprite(sf::seconds(0.15f));
    mSprite.setAnimation(mAnimation);
    sf::FloatRect bounds = mSprite.getLocalBounds();
    mSprite.setOrigin(bounds.width/2, bounds.height/2);
    mCurrentFacingDirection = Entity::FacingDirection::Left;

    if (waypoints.empty())
        mSeeking = true;

    //Position waypoints according to the bee center
    //Rather than absolute top-left coordinates
    else {
        for (auto &waypoint : waypoints) {
            sf::Vector2f platformWaypoint(
                waypoint.x + 35.f,
                waypoint.y + PX_PER_M - bounds.height / 2.f);
            mWaypoints.push_back(platformWaypoint);
        }
        mCurrentWaypoint = mWaypoints.begin();
    }
}
예제 #2
0
	void ObjectClue::draw() {

		if (!_caught) {

			if (isDebug()) {

				float* color = getBoundingSphere(0)->getColor();
				glPushMatrix();

					glDisable(GL_LIGHTING);

					glColor3f(color[0], color[1], color[2]);
					glTranslated(getBoundingSphere(0)->getPosition()[0], getBoundingSphere(0)->getPosition()[1], getBoundingSphere(0)->getPosition()[2]);
					glutWireSphere(getBoundingSphere(0)->getRadius(), 20, 20);

					glEnable(GL_LIGHTING);

				glPopMatrix();
			}

			TextureManager* tm = dynamic_cast<TextureManager*>( cg::Registry::instance()->get("TextureManager"));
			MaterialManager* mm = dynamic_cast<MaterialManager*>( cg::Registry::instance()->get("MaterialManager"));
			GLuint txClue = tm->get("clue")->getTextureDL();
			
			glPushMatrix();
				
				glEnable(GL_TEXTURE_2D);
				//mm->get("emerald")->apply();
				glTranslated(_position[0], _position[1], _position[2] + CLUE_SIZE / 2);
				glScalef(CLUE_SIZE, CLUE_SIZE, CLUE_SIZE);
				unitCube(txClue);
				glDisable(GL_TEXTURE_2D);
			glPopMatrix();
		}
	}
const Texture& getTexture(const std::string& path)
{
	if (!textureManager.isLoaded(path))
	{
		textureManager.load(path);
	}
	return textureManager.get(path);
}
예제 #4
0
파일: DoorEntity.cpp 프로젝트: vsrz/CS699
DoorEntity::DoorEntity(const TextureManager& textures, World* world)
	: Entity(world)
{
	mSprite.setTexture(textures.get(Textures::AutoDoors));
	setTilePosition(TilePosition(5,1));
	mSprite.setScale(world->getWorldScale());
	initalize();
}
예제 #5
0
SnakeSlime::SnakeSlime(TextureManager &textureManager, b2Body *enemyBody) : 
    Entity(enemyBody){

    sf::Texture &spriteSheet = textureManager.get(TextureID::EnemiesSpriteSheet);
    
    Animation wiggleAnimation;
    wiggleAnimation.setSpriteSheet(spriteSheet);
    wiggleAnimation.addFrame(sf::IntRect(424, 187, 53, 147));
    wiggleAnimation.addFrame(sf::IntRect(425, 40, 52, 147));
    mAnimation = wiggleAnimation;

    mSprite = AnimatedSprite(sf::seconds(0.15f));
    mSprite.setAnimation(mAnimation);
    sf::FloatRect bounds = mSprite.getLocalBounds();
    mSprite.setOrigin(bounds.width/2, bounds.height/2);
}
예제 #6
0
Projectile::Projectile(Type type, TextureManager& textures) :
	type(type),
	sprite(textures.get(getTexture()))
{
	sprite.setOrigin(sprite.getLocalBounds().width / 2.f, sprite.getLocalBounds().height / 2.f);
}