Beispiel #1
0
StoryScene::StoryScene(Game *o,std::string speech,int img,int theme):Scene(o,img,theme),m_speech(speech), m_timeMin(250)
							    , m_begin(0)
{
  m_readyToQuit = false;

  m_music = theme;
  m_bg = RectangleShape(Vector2f(WIDTH,HEIGHT));
  m_bg.setTexture( TextureLoader::instance()->get(img) );

  m_bar = RectangleShape(Vector2f(WIDTH,HEIGHT/5));
  m_bar.setFillColor(Color(255,255,255));
  m_bar.setOutlineThickness(10);
  m_bar.setOutlineColor(Color::Black);
  m_bar.setPosition(Vector2f(0, HEIGHT - m_bar.getLocalBounds().height));

 
  m_font.loadFromFile(DATA_PATH + "/font/elvifrance.ttf");
  m_text.setFont(m_font);
  m_text.setCharacterSize(20);
  m_text.setString(m_speech);
  m_text.setColor(Color::Black);
  m_text.setPosition(Vector2f(0,HEIGHT - m_bar.getLocalBounds().height - 20));


  m_clock.restart();
  m_timePlaying.restart();

  m_sizeMax = 50;
  m_lineMax = 3;
  m_begin = 0;
  m_end = m_sizeMax * m_lineMax;
  addLn();

}
Beispiel #2
0
void Quadtree::Split() {
    float sub_width = bounds_.width() / 2.0f;
    float sub_height = bounds_.height() / 2.0f;
    vec2f position = bounds_.position();

    children_[0] = new Quadtree(level_+1, RectangleShape(position.x + sub_width, position.y, sub_width, sub_height));
    children_[1] = new Quadtree(level_+1, RectangleShape(position.x, position.y, sub_width, sub_height));
    children_[2] = new Quadtree(level_+1, RectangleShape(position.x, position.y + sub_height, sub_width, sub_height));
    children_[3] = new Quadtree(level_+1, RectangleShape(position.x + sub_width, position.y + sub_height, sub_width,
            sub_height));
}
Beispiel #3
0
void demography  :: create_walls()
{
    //body definition
    b2BodyDef myBodyDef;
    myBodyDef.type = b2_staticBody;
    
    //shape definition
    b2PolygonShape polygonShape;
    polygonShape.SetAsBox(1, 1); //a 2x2 rectangle
    
    //fixture definition
    b2FixtureDef myFixtureDef;
    myFixtureDef.shape = &polygonShape;
    myFixtureDef.density = 1;
    myFixtureDef.restitution = 1;
    
    //a static body
    myBodyDef.type = b2_staticBody;
    myBodyDef.position.Set(0, 0);
    b2Body* staticBody = World.CreateBody(&myBodyDef);
    
    //        CircleShape * p = 0;
    staticBody->SetUserData(NULL);
    vector<b2Vec2> pos;
    vector<b2Vec2> size;
    
//    int coeff_x= 38;
//    int coeff_y= 29;
//    int coeff_x= 38;
//    int coeff_y= 29;
    b2Vec2 dims(wsize.x/SCALE,wsize.y/SCALE);
    int coeff_x = dims.x*.5,
    coeff_y = dims.y*.5;
    //top,bottom,left,right
    pos.push_back(b2Vec2(coeff_x,1));
    pos.push_back(b2Vec2(coeff_x,coeff_y*2));
    pos.push_back(b2Vec2(1,coeff_y));
    pos.push_back(b2Vec2(coeff_x*2,coeff_y));
    
    size.push_back(b2Vec2(coeff_x,1));
    size.push_back(b2Vec2(coeff_x,1));
    size.push_back(b2Vec2(1,coeff_y));
    size.push_back(b2Vec2(1,coeff_y));
    
    for(size_t a = 0; a < 4; ++a)
    {
        float w = size[a].x, h = size[a].y;
        Vector2f posit((pos[a].x)*SCALE,(pos[a].y)*SCALE);
        
        polygonShape.SetAsBox( w, h, pos[a], 0);//ground
        staticBody->CreateFixture(&myFixtureDef);
        walls.push_back(RectangleShape());
        walls.back().setSize(Vector2f(w*2*SCALE,2*h*SCALE));
        walls.back().setPosition(posit);
        walls.back().setFillColor(Color(50,50,50));
        recenter(walls.back());
        //            staticBody->SetUserData(0);
        staticBody->SetUserData(NULL);
    }
}
Beispiel #4
0
//Sets play area border sizes
PlayArea::PlayArea()
{
	width = 800;
	height = 600;
	borderSize = 50;
	enemyBorderWidth = 1800;

	//(800, 50)
	topBorder = RectangleShape(Vector2f(width, borderSize));
	bottomBorder = RectangleShape(Vector2f(width, borderSize));

	//(50, 600)
	rightBorder = RectangleShape(Vector2f(borderSize, height));
	leftBorder = RectangleShape(Vector2f(borderSize, height));

	//(1800, 50)
	enemyBorder = RectangleShape(Vector2f(enemyBorderWidth, borderSize));

	SetPositions();
}
Beispiel #5
0
void propagate::init(){
    auto dist = cfg->getint("propagate_dist");
    cfg->SET(spread_coeff);
    for(int i = -dist; i <=dist; ++i) 
        for(int j = -dist; j <=dist; ++j) 
            surnd.insert(Vec2i(i,j));
    surnd.erase(Vec2i(0,0));

    scale = (wsize.y*.9f)/p.pixels;
    hover=RectangleShape(Vec2(scale,scale));
    go=false;
    show_perlin =  cfg->getint("propagate_show_perlin");
}
Beispiel #6
0
 Label::Label (RenderWindow& window, math::Vec3f position, math::Vec3f size, const Font* font, std::string t) :
 LightComponent (window, position, size, size * 0.5f) {
     text.setFont(*font);
     text.setString(t);
     text.setSize(size);
     unsigned int maxSize = std::max(size.x, size.y);
     unsigned int nbChars = text.getString().length();
     unsigned int char_size;
     if (nbChars != 0)
         char_size = maxSize / nbChars;
     while (char_size * nbChars > size.x || char_size > size.y) {
         char_size--;
     }
     rect = RectangleShape (size);
     rect.setPosition(position);
     background = sf::Color::Black;
     rect.setFillColor(background);
 }
Beispiel #7
0
void Laser::setupShape()
{
	m_Rectangle = RectangleShape(m_Sprite.getSize());
}
Beispiel #8
0
void Asteroid::setupShape()
{
    m_Rectangle = RectangleShape(m_Sprite.getSize());
}
Beispiel #9
0
void CodeEditor::getPreferences() {
	Preferences *p = Preferences::instance();

	mFontSize = p->getFontSize();
	mTextColor = p->getTheme().textColor;
	mCursorColor = p->getTheme().cursorColor;
	mMarkColor = p->getTheme().markColor;
	mCurrentCharColor = p->getTheme().currentCharColor;
	mLineNumberAreaColor = p->getTheme().lineNumberAreaColor;
	mLineNumberTextColor = p->getTheme().lineNumberTextColor;
	mLineHighlightColor = p->getTheme().lineHighlightColor;
	mLineHighlightTextColor = p->getTheme().lineHighlightTextColor;
	mTabWidth = p->getTabWidth();
	mLineEnding = "\n"; //TODO: Make this an option.
	mShowLineNumbers = p->showLineNumbers();
	mUseTabs = p->useTabs();
	mShowMark = p->showMark();
	mShowLineHighlight = p->showLineHighlight();
	mLineHighlightType = p->getLineHighlightType();
	mScrollSpeed = p->getScrollSpeed();

	Font *font = p->getFont();
	Glyph g = font->getGlyph('a', mFontSize, false);
	mFontWidth = staticCastu32(g.advance);

	if (mShowLineNumbers) {
		mLineNumberAreaWidth = mFontSize * 3;
	} else {
		mLineNumberAreaWidth = 0;
	}

	if (mText.size() > 0) {
		for (int i = 0; i < mText.size(); ++i) {
			mText[i].setColor(mTextColor);
			mText[i].setCharSize(mFontSize);
			mText[i].setPosition(mPos.x + mLineNumberAreaWidth, mText[i].getPosition().y);
			mText[i].setFont(*font);
		}
	}

	if (mLineNumbers.size() > 0) {
		for (int i = 0; i < mLineNumbers.size(); ++i) {
			mLineNumbers[i].setColor(mLineNumberTextColor);
			mLineNumbers[i].setCharSize(mFontSize);
			mLineNumbers[i].setFont(*font);
		}
	}

	mLineNumberArea = RectangleShape(mLineNumberAreaWidth, 1920);
	mLineNumberArea.setFillColor(mLineNumberAreaColor);
	mLineNumberArea.setPosition(mPos.x, mPos.y);

	mCursorType = p->getCursorType();
	mBlinkCursor = p->cursorBlinks();
	mShowCursor = true;
	mLastBlinkTime = mClock.getCurrentTimeInMilliseconds();

	if (mCursorType == CursorType::Block) {
		mCursorRect = RectangleShape(g.advance,  font->getLineSpacing(mFontSize));
		mCursorRect.setFillColor(mCursorColor);
	} else if (mCursorType == CursorType::Outline) {
		mCursorRect = RectangleShape(g.advance,  font->getLineSpacing(mFontSize));
		mCursorRect.setOutlineColor(mCursorColor);
		mCursorRect.setOutlineThickness(1);
		mCursorRect.setFillColor(Color::Transparent);
	} else if (mCursorType == CursorType::Underscore) {
		mCursorRect = RectangleShape(g.advance,  2);
		mCursorRect.setFillColor(mCursorColor);
	} else {
		mCursorRect = RectangleShape(1,  font->getLineSpacing(mFontSize));
		mCursorRect.setFillColor(mCursorColor);
	}

	mMarkRect = RectangleShape(g.advance,  font->getLineSpacing(mFontSize));
	mMarkRect.setOutlineColor(mMarkColor);
	mMarkRect.setOutlineThickness(1);
	mMarkRect.setFillColor(Color::Transparent);

	mLineHighlightRect = RectangleShape(128, font->getLineSpacing(mFontSize));
	mLineHighlightRect.setFillColor(mLineHighlightColor);

	mCurrentChar = Text("", *font, mFontSize);
	mCurrentChar.setDoMultiColor(false);
	mCurrentChar.setColor(mCurrentCharColor);
	mCurrentChar.setPosition(mCursorRect.getPosition());

	//TODO: Topbar will be seperate widget, will be given a code editor to monitor.
	mTopBarText = Text("", *font, mFontSize);
	mTopBarText.setPosition(8, 22);
	mTopBarText.setColor(p->getTheme().barTextColor);

	mTopbar = RectangleShape(128, 22);
	mTopbar.setFillColor(p->getTheme().barColor);
	mTopbar.setPosition(mPos.x, 20);
}
Beispiel #10
0
void Player::updatePlayer()
{
	//Animation logic stuff
	if (flameAnim > animSteps){
		animAscend = false;
	}
	else if (flameAnim < -animSteps){
		animAscend = true;
	}



	//Collision checks
	//Borders
	if (!getExplosionState()){
		if (playerSprite.getPosition().y <= (playerSprite.getGlobalBounds().height / 2) || playerSprite.getPosition().y + (playerSprite.getGlobalBounds().height / 2) >= VideoMode::getDesktopMode().height){

			for (int i = 0; i < 2; i++){
				decreaseHealth(difficulty);
				if (getPlayerHealth() < 0){
					short num = -(getPlayerHealth());
					increaseHealth(num);
				}

				if (hardcore) setExplosionState(true);

				updateCrashSound();

				if (showParticles){
					crashDebrisSpeed.push_back(Vector2f(-(getObstacleBaseSpeed() / 2), getRandom(-2, 2)));
	
					crashDebris.push_back(RectangleShape());
					short ramNum = getRandom(5, 8);
					crashDebris.back().setSize(Vector2f(ramNum, ramNum));
					crashDebris.back().setOrigin(ramNum / 2, ramNum / 2);
					ramNum = getRandom(50, 160);
					crashDebris.back().setFillColor(Color::Color(ramNum, ramNum, ramNum));
					crashDebris.back().setPosition(collisionCircle[0].getPosition().x + getRandom(-5, 5), collisionCircle[0].getPosition().y + getRandom(-5, 5));
				}	
			}
		}

		//Obstacles
		for (int i=0; i<getNumberOfObstacles(); i++){
			if (playerCollision(&collisionCircle[0], &getObstacleObject(i))){
				if (getPlayerHealth() > 0) decreaseHealth(difficulty);
				if (getPlayerHealth() < 0){
					short num = -(getPlayerHealth());
					increaseHealth(num);
				}

				if (hardcore) setExplosionState(true);

				updateCrashSound();
	
				if (showParticles){
					crashDebrisSpeed.push_back(Vector2f(-(getObstacleBaseSpeed() / 2), getRandom(-2, 2)));
			
					crashDebris.push_back(RectangleShape());
					short ramNum = getRandom(5, 8);
					crashDebris.back().setSize(Vector2f(ramNum, ramNum));
					crashDebris.back().setOrigin(ramNum / 2, ramNum / 2);
					ramNum = getRandom(50, 160);
					crashDebris.back().setFillColor(Color::Color(ramNum, ramNum, ramNum));
					crashDebris.back().setPosition(collisionCircle[0].getPosition().x + getRandom(-5, 5), collisionCircle[0].getPosition().y + (getRandom(-5, 5)));
				}
			}

			if (playerCollision(&collisionCircle[1], &getObstacleObject(i))){
				if (getPlayerHealth() > 0) decreaseHealth(difficulty);
				if (getPlayerHealth() < 0){
					short num = -(getPlayerHealth());
					increaseHealth(num);
				}

				if (hardcore) setExplosionState(true);

				updateCrashSound();
			
				if (showParticles){
					crashDebrisSpeed.push_back(Vector2f(-(getObstacleBaseSpeed() / 2), getRandom(-2, 2)));

					crashDebris.push_back(RectangleShape());
					short ramNum = getRandom(4, 7);
					crashDebris.back().setSize(Vector2f(ramNum, ramNum));
					crashDebris.back().setOrigin(ramNum / 2, ramNum / 2);
					ramNum = getRandom(50, 160);
					crashDebris.back().setFillColor(Color::Color(ramNum, ramNum, ramNum));
					crashDebris.back().setPosition(collisionCircle[1].getPosition().x + getRandom(-3, 3), collisionCircle[1].getPosition().y + (getRandom(-3, 3)));
				}
			}

			if (playerCollision(&collisionCircle[2], &getObstacleObject(i))){
				if (getPlayerHealth() > 0) decreaseHealth(difficulty);
				if (getPlayerHealth() < 0){
					short num = -(getPlayerHealth());
					increaseHealth(num);
				}

				if (hardcore) setExplosionState(true);

				updateCrashSound();
			
				if (showParticles){
					crashDebrisSpeed.push_back(Vector2f(-(getObstacleBaseSpeed() / 2), getRandom(-2, 2)));

					crashDebris.push_back(RectangleShape());
					short ramNum = getRandom(4, 7);
					crashDebris.back().setSize(Vector2f(ramNum, ramNum));
					crashDebris.back().setOrigin(ramNum / 2.0f, ramNum / 2.0f);
					ramNum = getRandom(50, 160);
					crashDebris.back().setFillColor(Color::Color(ramNum, ramNum, ramNum));
					crashDebris.back().setPosition(collisionCircle[2].getPosition().x + getRandom(-3, 3), collisionCircle[2].getPosition().y + (getRandom(-3, 3)));
				}
			}
		}
	}

	//Explosion
	if (getPlayerHealth() <= 0 || getExplosionState()){
		setExplosionState(true);
		decreaseFuel(getPlayerFuel());
		updateExplosionText();
		stopRocketSound();
		stopAlarmSound();
		stopCrashSound();

		if (initExplosion){
			for (int i = 0; i < 200; i++){
				crashDebrisSpeed2.push_back(Vector2f(getRandom(-2, 2), getRandom(-2, 2)));

				crashDebris2.push_back(RectangleShape());
				short ramNum = getRandom(4, 7);
				crashDebris2.back().setSize(Vector2f(ramNum, ramNum));
				crashDebris2.back().setOrigin(ramNum / 2.0f, ramNum / 2.0f);
				ramNum = getRandom(50, 160);
				crashDebris2.back().setFillColor(Color::Color(ramNum, ramNum, ramNum));
				crashDebris2.back().setPosition(collisionCircle[0].getPosition().x + getRandom(-3, 3), collisionCircle[0].getPosition().y + (getRandom(-3, 3)));


				damageParticleSpeed2.push_back(Vector2f(getRandom(-3, 3), getRandom(-3, 3)));

				damageParticle2.push_back(CircleShape());
				damageParticle2.back().setRadius(getRandom(1, 2));
				damageParticle2.back().setFillColor(Color::Color(255, 153, 51));
				int j = getRandom(0, 2);
				damageParticle2.back().setPosition(collisionCircle[0].getPosition().x + getRandom(-3, 3), collisionCircle[0].getPosition().y + (getRandom(-3, 3)));
			}

			playExplosionSound();
		}

		for (int i = 0; i < crashDebris2.size(); i++){
			crashDebris2[i].move(crashDebrisSpeed2[i].x - explosionSpeedCounter, crashDebrisSpeed2[i].y);
			if (i % 2 == 0){
				crashDebris2[i].rotate(2);
			}
			else crashDebris2[i].rotate(-2);

			crashDebrisSpeed2[i].x = crashDebrisSpeed2[i].x * 0.985;
			crashDebrisSpeed2[i].y = crashDebrisSpeed2[i].y * 0.985;

			if (crashDebris2[i].getPosition().x < -10){
				crashDebris2.erase(crashDebris2.begin() + i);
				crashDebrisSpeed2.erase(crashDebrisSpeed2.begin() + i);
			}
		}
		for (int i = 0; i < damageParticleSpeed2.size(); i++){
			damageParticle2[i].move(damageParticleSpeed2[i].x - explosionSpeedCounter, damageParticleSpeed2[i].y);

			damageParticleSpeed2[i].x = damageParticleSpeed2[i].x * 0.985;
			damageParticleSpeed2[i].y = damageParticleSpeed2[i].y * 0.985;

			if (damageParticle2[i].getPosition().x < -10){
				damageParticle2.erase(damageParticle2.begin() + i);
				damageParticleSpeed2.erase(damageParticleSpeed2.begin() + i);
			}

		}

		if (explosionSpeedCounter <= 10.0){
			explosionSpeedCounter *= 1.03;
		}

		initExplosion = false;

		if (Keyboard::isKeyPressed(Keyboard::R)){
			setCrashState(true);
			setExplosionState(false);
		}
		else if (Keyboard::isKeyPressed(Keyboard::Escape)) setExitState(true);
	}


	//Updates
	//Crash debris
	if (showParticles){
		for (int i = 0; i < crashDebris.size(); i++){
			crashDebris[i].move(crashDebrisSpeed[i].x, crashDebrisSpeed[i].y);
		
			if (i % 2 == 0) crashDebris[i].rotate(10);
				else crashDebris[i].rotate(-10);

			if (crashDebris[i].getPosition().x < -20){
				crashDebris.erase(crashDebris.begin() + i);
				crashDebrisSpeed.erase(crashDebrisSpeed.begin() + i);
			}
		}

	//Damage particles
		if (getPlayerHealth() > 0 && getPlayerHealth() <= 75){
		
			if (1 >= getRandom(0, 10)){
				damageParticleSpeed.push_back(Vector2f(-(getObstacleBaseSpeed()), 0));

				damageParticle.push_back(CircleShape());

				damageParticle.back().setRadius(1);
				damageParticle.back().setFillColor(Color::Color(255, 153, 51));
				int i = getRandom(0, 2);
				damageParticle.back().setPosition(collisionCircle[i].getPosition().x + getRandom(-3, 3), collisionCircle[i].getPosition().y + (getRandom(-3, 3)));
			}
		}
		if (getPlayerHealth() > 0 && getPlayerHealth() <= 50){
		
			if (1 >= getRandom(0, 5)){
				damageParticleSpeed.push_back(Vector2f(-(getObstacleBaseSpeed()), 0));

				damageParticle.push_back(CircleShape());
			
				damageParticle.back().setRadius(1);
				damageParticle.back().setFillColor(Color::Color(255, 153, 51));
				int i = getRandom(0, 2);
				damageParticle.back().setPosition(collisionCircle[i].getPosition().x + getRandom(-3, 3), collisionCircle[i].getPosition().y + (getRandom(-3, 3)));
			}
		}
		if (getPlayerHealth() > 0 && getPlayerHealth() <= 25){
		
			if (1 >= getRandom(0, 2)){
				damageParticleSpeed.push_back(Vector2f(-(getObstacleBaseSpeed()), 0));

				damageParticle.push_back(CircleShape());
			
				damageParticle.back().setRadius(1);
				damageParticle.back().setFillColor(Color::Color(255, 153, 51));
				int i = getRandom(0, 2);
				damageParticle.back().setPosition(collisionCircle[i].getPosition().x + getRandom(-3, 3), collisionCircle[i].getPosition().y + (getRandom(-3, 3)));
			}

			if (1 >= getRandom(0, 50)){

			}
		}

		for (int i = 0; i < damageParticle.size(); i++){
			damageParticle[i].move(damageParticleSpeed[i].x, damageParticleSpeed[i].y);

			if (damageParticle[i].getPosition().x < -10){
				damageParticle.erase(damageParticle.begin() + i);
				damageParticleSpeed.erase(damageParticleSpeed.begin() + i);
			}
		}
	}

	if (getPlayerFuel() > 0 && getPlayerHealth() > 0){

		if (controlScheme == 1){
			if (Keyboard::isKeyPressed(Keyboard::Space)){
				if (playerRotation >= -30){
					playerRotation -= 15;
					if (playerRotation < -30) playerRotation = playerRotation - (playerRotation + 30);
					playerSprite.setRotation(playerRotation);
				}

				playerSprite.move(0, baseClimingSpeed); //Climing speed is always constant
	
				playerSpeed = -(baseFallingSpeed +3); //Set speed value so that transition from climing to falling feels smooth
			}
			else {
				if (playerRotation <= 20){
					playerRotation += 5;
					playerSprite.setRotation(playerRotation);
				}

				playerSprite.move(0, baseFallingSpeed + playerSpeed);
		
				if (playerSpeed <= 0) playerSpeed = playerSpeed + 1;
				else if ((playerSpeed <= baseFallingSpeed) && (playerSpeed > 0)) playerSpeed = playerSpeed * 1.02;
			}
		}
		else if (controlScheme == 2){
			if (Keyboard::isKeyPressed(Keyboard::Left) && playerRotation >= -30){
				playerRotation -= 3;
			}
			
			else if (Keyboard::isKeyPressed(Keyboard::Right) && playerRotation <= 30){
				playerRotation += 3;
			}
			else if (Keyboard::isKeyPressed(Keyboard::Space)){
				playerRotation = 0;
			}
			
			playerSprite.setRotation(playerRotation);
			playerSprite.move(0, playerRotation / 3);
		}
		else if (controlScheme == 3){
			if (Keyboard::isKeyPressed(Keyboard::Left)){
				if (playerRotation >= -30) playerRotation -= 5;
			}
			
			else if (Keyboard::isKeyPressed(Keyboard::Right)){
				if (playerRotation <= 30) playerRotation += 5;
			}
			else {
				if (playerRotation < 0){
					playerRotation += 5;
				}
				else if (playerRotation > 0) playerRotation -= 5;
			}
			
			playerSprite.setRotation(playerRotation);
			playerSprite.move(0, playerRotation / 3);
		}

		if (getPlayerHealth() > 0) updateRocketSound();
	}
	else if (getPlayerFuel() <= 0){
		if (!playedShutdownSound){
			playShutdownSound();
			playedShutdownSound = true;
		}

		stopRocketSound();

		if (playerRotation < 0) playerSprite.move(0, playerRotation / 6);
		else if (playerRotation > 0) playerSprite.move(0, playerRotation / 3);

		if (playerRotation < 0) playerSprite.rotate(-1);
		else if (playerRotation > 0) playerSprite.rotate(1);
	}
	

	//Flame Sprite Bottom
	flameSpriteBottom.setPosition((playerSprite.getPosition().x - 45) - (playerRotation / 2.4), (playerSprite.getPosition().y + 28) + -(playerRotation / 1.05));
	flameSpriteBottom.setRotation(playerSprite.getRotation());

	if (animAscend){
		flameScale += 0.012;
		flameSpriteBottom.setScale(flameScale, flameSpriteBottom.getScale().y);
		flameAnim++;
	}
	else if (!animAscend){
		flameScale -= 0.012;
		flameSpriteBottom.setScale(flameScale, flameSpriteBottom.getScale().y);
		flameAnim--;
	}


	//Flame Sprite Top
	flameSpriteTop.setPosition(playerSprite.getPosition().x - 45, (playerSprite.getPosition().y - 7) + -(playerRotation / 1.05));
	flameSpriteTop.setRotation(playerSprite.getRotation());

	if (animAscend){
		flameScale += 0.012;
		flameSpriteTop.setScale(flameScale, flameSpriteBottom.getScale().y);
		flameAnim++;
	}
	else if (!animAscend){
		flameScale -= 0.012;
		flameSpriteTop.setScale(flameScale, flameSpriteBottom.getScale().y);
		flameAnim--;
	}

	collisionCircle[0].setPosition(playerSprite.getPosition().x + 20, playerSprite.getPosition().y + ((playerRotation / 3) + 2));
	collisionCircle[1].setPosition(playerSprite.getPosition().x - (24 - (playerRotation / 5)), playerSprite.getPosition().y - ((playerRotation / 2) + 12));
	collisionCircle[2].setPosition(playerSprite.getPosition().x - (24 + (playerRotation / 5)), playerSprite.getPosition().y - ((playerRotation / 2) - 14));
}
Beispiel #11
0
void Powerup::setupShape()
{
	m_Rectangle = RectangleShape(m_Sprite.getSize());
}
Beispiel #12
0
void game :: menu(){
    int sub_choice= 0;
    string hl ="none";
    map<string,RectangleShape> rects;
    map<string,Sprite> sprites;
    map<string,Texture> textures;
    map<string,Text> texts;
    confload menu_conf;
    menu_conf.init("menu.cfg");
    auto v = menu_conf.getlist("demos");
    decltype(v) v2;
    for(auto&a:v)
    {
        if (lambdas.count("load_" + a))
        {
            v2.push_back(a);
            //msg("found " + a);
        }
        //else
        //    msg(a+" was not found");
    }
    auto many = 1+int(sqrt(v2.size()));
    int i = 0;
    auto cellsize = .9f*Vec2(wsize.x/many,wsize.y/many);

    for(auto a:v2)
    {
        int x = i%many;
        int y = i/many;


        rects[a]=RectangleShape(cellsize);
        rects[a].setPosition(1.05f*Vec2(cellsize.x*x,cellsize.y*y));
        rects[a].setFillColor(Color(128,128,128,16));
        texts[a]=Text(a,*font1,charsize);
        texts[a].setPosition(1.05f*Vec2(cellsize.x*x,cellsize.y*y));

        if(!textures[a].loadFromFile("thumbs/"+a+".png"))
            cout << "could not open "+a+".png" << endl;
        else
        {
            cout << "loaded "+a+".png" << endl;
            sprites[a].setTexture(textures[a]);
            sprites[a].setPosition(1.05f*Vec2(cellsize.x*x,cellsize.y*y));

            auto rect = rects[a].getLocalBounds();
            sprites[a].setTextureRect(IntRect(rect));
        }



        ++i;
    }
    ////////// loop //////////
    while(!sub_choice && window.isOpen())
    {
        for(auto & a: rects)
        {
            if(a.second.getLocalBounds().contains(mouse_pos-a.second.getPosition()))
            {a.second.setFillColor(Color(128,128,128,64));hl = a.first;}
            else a.second.setFillColor(Color(128,128,128,16));
        }
        ///////
        Event event;
        window.clear(bg);
        if (window.pollEvent(event)) // PREFER WHILE
        {
            if(event.type == sf::Event::Closed || (
                event.type == sf:: Event::KeyPressed
                && event.key.code == sf::Keyboard::Escape))
                    window.close();
                //{ keep_going = false; return; }
            if(event.type == sf::Event::MouseButtonPressed)
                if(hl!="none") {load_gameobj(hl);sub_choice = 1;}
            if(event.type == sf::Event::MouseMoved)
            {
                mouse_pos = Vec2(event.mouseMove.x,event.mouseMove.y);
                cursor.setPosition(mouse_pos);
            }
        }
            /*  treatevent(event);*/
        for(auto a:sprites) window.draw(a.second);
        for(auto a:rects) window.draw(a.second);
        for(auto a:texts) window.draw(a.second);
        //window.setView(fixedview);
        labs->draw(window);
        console->draw(window);
        window.draw(cursor);

        window.display();
    }
}