コード例 #1
0
ファイル: renderer.cpp プロジェクト: Eldhelion/keeperrl
void Renderer::drawFilledRectangle(const Rectangle& t, Color color, optional<Color> outline) {
  addRenderElem([this, t, color, outline] {
      static RectangleShape r;
      r.setSize(Vector2f(t.getW(), t.getH()));
      r.setPosition(t.getPX(), t.getPY());
      r.setFillColor(color);
      if (outline) {
        r.setOutlineThickness(-2);
        r.setOutlineColor(*outline);
      } else
        r.setOutlineThickness(0);
      display.draw(r);
  });
}
コード例 #2
0
ファイル: misc.cpp プロジェクト: dridk/tankfighter
void drawSprite(Sprite &spr, RenderTarget &target) {
	RectangleShape shape;
	Texture &sftexture = const_cast<Texture&>(*spr.getTexture());
	FloatRect r = spr.getLocalBounds();
	shape.setSize(Vector2f(r.width, r.height));
	shape.setOrigin(spr.getOrigin());
	shape.setRotation(spr.getRotation());
	shape.setPosition(spr.getPosition());
	shape.setScale(spr.getScale());
	shape.setTexture(spr.getTexture());
	shape.setFillColor(spr.getColor());
	sftexture.setRepeated(false);
	target.draw(shape);
	sftexture.setRepeated(true);
}
コード例 #3
0
void PlayState::setBackground()
{
	
	for (int j = 0; j < Game::SCRN_WIDTH / Game::APPLE_SIZE; j++)
		for (int i = 0; i < Game::SCRN_HEIGHT / Game::APPLE_SIZE; i++)
		{
			RectangleShape square;
			square.setSize(Vector2f((float)Game::APPLE_SIZE, (float)Game::APPLE_SIZE));
			square.setFillColor(Color::Black);
			square.setOutlineThickness(-1.f);
			square.setOutlineColor(Color(55, 55, 55));
			square.setPosition(Vector2f(j*(float)Game::APPLE_SIZE, i*(float)Game::APPLE_SIZE));
			mapTiles.push_back(square);	
		}
	
}
コード例 #4
0
ファイル: game.cpp プロジェクト: erikkacsm/encounters
void drawShipInfo(RenderWindow& window, int shipIndex, string shipInfo) {
	Text name;
	Text info;

	name.setString(SHIPS[shipIndex]);
	info.setString(shipInfo);

	name.setFont(titleFont);
	info.setFont(infoFont);
	name.setCharacterSize(25);
	info.setCharacterSize(17);
	name.setColor(Color(255, 157, 61));
	info.setColor(Color(255, 199, 125));

	RectangleShape textBG;
	textBG.setFillColor(Color(22, 24, 37, 200));
	textBG.setOutlineColor(Color(76, 87, 128, 255));
	textBG.setOutlineThickness(1);

	// set up bounds for text box
	int titleTop;
	int infoTop;
	int infoBottom;
	int left;
	int right;

	titleTop = 419 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	left = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		511 - name.getLocalBounds().width / 2 :
		511 - info.getLocalBounds().width / 2;
	infoTop = 419 + name.getLocalBounds().height + 15 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	infoBottom = info.getLocalBounds().height + infoTop;
	right = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		left + name.getLocalBounds().width :
		left + info.getLocalBounds().width;

	// position and draw text box
	name.setPosition(Vector2f(left, titleTop));
	info.setPosition(Vector2f(left, infoTop));
	textBG.setSize(Vector2f(right - left + 20, infoBottom - titleTop + 20));
	textBG.setPosition(Vector2f(left - 10, titleTop - 3));

	window.draw(textBG);
	window.draw(name);
	window.draw(info);
}
コード例 #5
0
ファイル: snake.cpp プロジェクト: Babanar/Snake
void Snake::afficher(sf::RenderWindow * _window){
    int colorByQuad = 200/corps.size();
    for(int i=0;i<corps.size();i++){
        partCorps.setFillColor(Color(10,255-(i*colorByQuad),10));
        partCorps.setPosition(Vector2f(corps[i].x*partSize,corps[i].y*partSize));
        _window->draw(partCorps);
    }
    _window->draw(partFood);
    if(loose){
            RectangleShape tmp;
    tmp.setFillColor(Color(50,0,0,127));
    tmp.setPosition(0,0);
    tmp.setSize(Vector2f(largeur,hauteur));
        _window->draw(tmp);
        _window->draw(text);
        _window->draw(text2);
    }
}
コード例 #6
0
ファイル: main2.cpp プロジェクト: FirKys/session_2
	Player(int player, float x, float y){
		// == Создание игрока ==
		rectangle.setPosition(Vector2f(x, y));		//Позиция игрока
		this->player = player;						//ID игрока
		rectangle.setSize(Vector2f(20, 20));		//Размер
		rectangle.setFillColor(Color::Green);		//Цвет

		// == Создание пушки ==
		Vector2f centerTank = { 0, 0 };
		centerTank.x = rectangle.getPosition().x + (rectangle.getSize().x / 2);	//Центр танка по x
		centerTank.y = rectangle.getPosition().y + (rectangle.getSize().y / 2);	//Центр танка по y

		turret.setPrimitiveType(LinesStrip);

		turret.append(centerTank);	//Начало пушки из танка
		centerTank.y -= 25;
		turret.append(centerTank);	//Смещение по y на 10
	};
コード例 #7
0
void UIComponentTreeViewItem::onRender(Renderer* renderer, UIView* view)
{
	// Render this item full size

	/*RectangleShape back;
	back.setRect(view->getBounds());
	back.setColor(Color::Red);
	renderer->draw(back);*/

	// Render a little expandable flag if it applies
	if(mParent->getChildCount() > 0)
	{
		RectangleShape back;
		back.setRect(mParent->getChild(0)->getBounds());
		back.setSize(5.f, back.getSize().y);
		back.setColor(Color::Red);
		renderer->draw(back);
	}
}
コード例 #8
0
void StateTransitionBlocks::onUpdate(const Time& time)
{
	if(!m_next)
	{
		remainingTime -= time.asSeconds();

		if(remainingTime <= 0.f && !positions.empty())
		{
			vec2 p = positions.back();
			positions.pop_back();

			RectangleShape shape;
			shape.setColor(Color::Black);
			shape.setSize(blockSize,blockSize);
			shape.setPosition(p.x, p.y);
			shapes.push_back(shape);

			remainingTime = 0.005f;
		}

		if(positions.empty())
			m_next = true;
	}
	else
	{
		remainingTime -= time.asSeconds();

		if(remainingTime <= 0.f)
		{
			if(shapes.size() > 0) shapes.pop_back();

			remainingTime = 0.005f;
		}

		if(shapes.empty())
		{
			Log("Transition ended");
			finish();
		}
	}

}
コード例 #9
0
ファイル: main.cpp プロジェクト: Yoggiburken/Good-bye
void intro()
{
	Sprite firecan;
	firecan.setTexture(MediaBucket.getTexture("firecan"));
	firecan.setOrigin(firecan.getLocalBounds().width/2, firecan.getLocalBounds().height/2);
	firecan.setPosition(400, 300);
	Time	intro_time = seconds(4);
	Clock 	clock;

	double opacity = 255;

	RectangleShape filter;
	filter.setFillColor(Color(255,255,255,opacity));
	filter.setSize(Vector2f(800,600));
	filter.setOrigin(400,300);
	filter.setPosition(400,300);

	while(intro_time > seconds(0)) 
	{
		while(app.pollEvent(event))
		{
			if(event.type == Event::KeyPressed) {
				if(event.key.code == Keyboard::Escape) {
					intro_time = seconds(0);
				}
			}
		}
		elapsed_time = clock.restart();
		intro_time -= elapsed_time;
		if(opacity >= 0) {
			opacity -= 255/2*elapsed_time.asSeconds();
			if(opacity < 0) {
				opacity = 0;
			}
		}
		filter.setFillColor(Color(255,255,255,opacity));
		app.clear(Color::White);
		app.draw(firecan);
		app.draw(filter);
		app.display();
	}
}
コード例 #10
0
void FluidTerrain::draw(){
    double tileSize = (double)width/(double)chunk.chunkSize;
    for (int i = 0; i < chunk.chunkSize; i++){
        for (int j = 0; j < chunk.chunkSize; j++){
            RectangleShape cell;
            cell.setPosition(i*tileSize, j*tileSize);
            cell.setSize(Vector2f(tileSize, tileSize));
            
            if (chunk.terrain[i][j] == forest)
                cell.setFillColor(Color(255, 0, 0, 255));
            else if (chunk.terrain[i][j] == desert)
                cell.setFillColor(Color(0, 255, 0, 255));
            else if (chunk.terrain[i][j] == plain)
                cell.setFillColor(Color(0, 0, 255, 255));
            else if (chunk.terrain[i][j] == tom)
                cell.setFillColor(Color(0, 0, 0, 255)); 
    
            window.draw(cell);
        }
    }
}
コード例 #11
0
void RenderSystem::update(float dt, std::vector<GameObject*>* objects)
{
	for (Ite i = objects->begin(); i != objects->end(); i++)
	{
		RenderComponent* render = (*i)->getComponent<RenderComponent>();
		if (render != nullptr)
		{
			RectangleShape shape = *render->getDrawable();
			PhysicsComponent* physics = (*i)->getComponent<PhysicsComponent>();
			if (physics != nullptr)
			{
				Vector2f position = mScale * flipY(physics->getBody()->GetPosition());
				shape.setPosition(position);
				shape.setSize(1.02f * mScale * physics->getSize());
				shape.setOrigin(shape.getSize() * 0.5f);

				// positive direction is opposite in Box2D
				shape.setRotation(-1.0f * physics->getBody()->GetAngle() * 180 / b2_pi);
			}
			mWindow->draw(shape);
		}
	}
}
コード例 #12
0
ファイル: game.cpp プロジェクト: erikkacsm/encounters
void drawAbilityInfo(RenderWindow& window, Player& player, int abilityIndex, bool available) {

	// set up text boxes
	Text name;
	Text info;
	Text cooldownInfo;

	cooldownInfo.setString(
		available ?
		"Available to use!" :
		"Can't use right now!"
		);

	name.setFont(titleFont);
	info.setFont(infoFont);
	cooldownInfo.setFont(infoFont);
	name.setCharacterSize(25);
	info.setCharacterSize(17);
	cooldownInfo.setCharacterSize(17);
	name.setColor(Color(0, 255, 114));
	info.setColor(Color(147, 255, 196));
	cooldownInfo.setColor(available ? Color(0, 255, 114) : Color::Red);

	RectangleShape textBG;
	textBG.setFillColor(Color(22, 21, 40, 200));
	textBG.setOutlineColor(Color(71, 66, 128, 255));
	textBG.setOutlineThickness(1);

	RectangleShape cooldownBG;
	cooldownBG.setFillColor(Color(22, 21, 40, 200));
	cooldownBG.setOutlineColor(Color(71, 66, 128, 255));
	cooldownBG.setOutlineThickness(1);

	// set bounds for text boxes
	int titleTop;
	int infoTop;
	int infoBottom;
	int left;
	int right;
	int cooldownLeft;
	int cooldownRight;
	int cooldownTop;
	int cooldownBottom;

	name.setString(player.abilities[abilityIndex].abilityName);
	info.setString(player.abilities[abilityIndex].abilityDescription);

	titleTop = 410 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	left = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		400 - name.getLocalBounds().width / 2 :
		400 - info.getLocalBounds().width / 2;
	infoTop = 410 + name.getLocalBounds().height + 15 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	infoBottom = info.getLocalBounds().height + infoTop;
	right = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		left + name.getLocalBounds().width :
		left + info.getLocalBounds().width;
	cooldownLeft = 400 - cooldownInfo.getLocalBounds().width / 2;
	cooldownRight = cooldownLeft + cooldownInfo.getLocalBounds().width;
	cooldownTop = infoBottom + 35;
	cooldownBottom = cooldownTop + cooldownInfo.getLocalBounds().height;

	// position and draw text boxes
	name.setPosition(Vector2f(left, titleTop));
	info.setPosition(Vector2f(left, infoTop));
	cooldownInfo.setPosition(Vector2f(cooldownLeft, cooldownTop));

	textBG.setSize(Vector2f(right - left + 20, infoBottom - titleTop + 20));
	textBG.setPosition(Vector2f(left - 10, titleTop - 3));
	cooldownBG.setPosition(Vector2f(cooldownLeft - 10, cooldownTop - 4));
	cooldownBG.setSize(Vector2f(cooldownRight - cooldownLeft + 20, cooldownBottom - cooldownTop + 20));

	window.draw(cooldownBG);
	window.draw(textBG);
	window.draw(name);
	window.draw(info);
	window.draw(cooldownInfo);
}
コード例 #13
0
ファイル: game.cpp プロジェクト: erikkacsm/encounters
// draws health bars, buff icons, main background
void drawGameWindow(RenderWindow& window, Player& human, Player& computer) {

	Sprite background;
	background.setTexture(backgroundTexture);
	window.draw(background);

	RectangleShape humanHealth;			// used to cover up buffs
	RectangleShape computerHealth;		// that aren't in effect
	RectangleShape humanResources;
	RectangleShape computerResources;
	RectangleShape iconCovers[8];

	for (int i = 0; i < 8; i++) {
		iconCovers[i].setFillColor(Color(0, 0, 0, 191));
		iconCovers[i].setSize(Vector2f(91, 27));
	}

	iconCovers[0].setPosition(Vector2f(3, 328));
	iconCovers[1].setPosition(Vector2f(3, 372));
	iconCovers[2].setPosition(Vector2f(3, 416));
	iconCovers[3].setPosition(Vector2f(3, 460));
	iconCovers[4].setPosition(Vector2f(705, 328));
	iconCovers[5].setPosition(Vector2f(705, 372));
	iconCovers[6].setPosition(Vector2f(705, 416));
	iconCovers[7].setPosition(Vector2f(705, 460));

	humanHealth.setSize(Vector2f(386, 45));
	humanHealth.setPosition(Vector2f(13, 13));
	humanHealth.setFillColor(Color::Black);
	humanHealth.setScale(Vector2f(1 - float(human.currentHealth) / human.totalHealth, 1));

	computerHealth.setOrigin(Vector2f(386, 0));
	computerHealth.setSize(Vector2f(386, 45));
	computerHealth.setPosition(Vector2f(787, 13));
	computerHealth.setFillColor(Color::Black);
	computerHealth.setScale(Vector2f(1 - float(computer.currentHealth) / computer.totalHealth, 1));

	humanResources.setSize(Vector2f(199, 32));
	humanResources.setPosition(Vector2f(200, 86));
	humanResources.setFillColor(Color::Black);
	humanResources.setScale(Vector2f(1 - float(human.currentResources) / human.totalResources, 1));

	computerResources.setOrigin(Vector2f(199, 0));
	computerResources.setSize(Vector2f(199, 32));
	computerResources.setPosition(Vector2f(600, 86));
	computerResources.setFillColor(Color::Black);
	computerResources.setScale(Vector2f(1 - float(computer.currentResources) / computer.totalResources, 1));

	if (human.shield.empty()) window.draw(iconCovers[0]);
	if (human.stun.empty()) window.draw(iconCovers[1]);
	if (human.damageBuff.empty()) window.draw(iconCovers[2]);
	if (human.damageDebuff.empty()) window.draw(iconCovers[3]);
	if (computer.shield.empty()) window.draw(iconCovers[4]);
	if (computer.stun.empty()) window.draw(iconCovers[5]);
	if (computer.damageBuff.empty()) window.draw(iconCovers[6]);
	if (computer.damageDebuff.empty()) window.draw(iconCovers[7]);

	window.draw(humanResources);
	window.draw(computerResources);
	window.draw(humanHealth);
	window.draw(computerHealth);
}
コード例 #14
0
std::string name_enter(RenderWindow &window){

    Font font;

    std::string str;
    String text;

    font.loadFromFile("arial.ttf");

    Text name, text_ent, too_many_letters;

    bool flag = false;
    float timer = 100;
    name.setFont(font);
    name.setCharacterSize(30);
    name.setColor(Color::Black);
    name.setPosition(500, 300);

    RectangleShape rect;
    rect.setFillColor(Color::Magenta);
    rect.setOutlineThickness(5);
    rect.setOutlineColor(Color::Black);
    rect.setSize(Vector2f(120, 40));
    rect.setPosition(500, 300);

    text_ent.setFont(font);
    text_ent.setString("Enter your name. Less then 8 letters please. When you will be ready, press \"spase\"");
    text_ent.setCharacterSize(30);
    text_ent.setColor(Color::Black);
    text_ent.setPosition(50, 200);

    too_many_letters.setFont(font);
    too_many_letters.setString("To many letters");
    too_many_letters.setCharacterSize(40);
    too_many_letters.setColor(Color::Red);
    too_many_letters.setPosition(730, 300);

    std::string s = "";

    while(window.isOpen()){

        sf::Event event;
        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed)
                window.close();
            if (event.type == sf::Event::TextEntered){
                if(Keyboard::isKeyPressed(Keyboard::BackSpace) && s.size()!=0){
                    if (!s.empty())
                        s.pop_back();
                }
                else if (s.size() >= 7) {
                    flag = true;
                    timer = 100;
                }
                else if (event.text.unicode < 128 && s.size() < 7 && !flag) {
                    s.push_back((char)event.text.unicode);
                }
                if(Keyboard::isKeyPressed(Keyboard::Space) && s.size()!=0){
                    return s;
                }
            }
        }
        if(Keyboard::isKeyPressed(Keyboard::Escape))
            return "escape_code";

        window.clear(Color::Green);
        name.setString(s);
        window.draw(rect);
        if(flag){
            window.draw(too_many_letters);
            timer = timer * 0.7;
            if(timer < 10)
                flag = false;
        }
        window.draw(name);
        window.draw(text_ent);
        window.display();
    }
}
コード例 #15
0
ファイル: Simulation.cpp プロジェクト: theTI2O/GravityLaw
void Simulation::testons()
{
    Event event;
    while(m_window.pollEvent(event))
    {
        if(event.type == Event::Closed)
            m_window.close();

        if(event.type == Event::MouseButtonReleased)//Si on clique, on ajoute un corps
        {
            if(event.mouseButton.button == Mouse::Left)
            {
                Vector2i mousePosition = Mouse::getPosition(m_window);

                m_test.setPosition(mousePosition.x, mousePosition.y);

            }
        }
    }

    //données:
    CircleShape cercle;
    CircleShape base;

    base.setPosition(390, 390);
    base.setRadius(10);
    base.setFillColor(Color::Red);



    double x(0), y(0), rayon(5);
    //int color[3];

    m_test.getPosition(x, y);

    m_window.clear(Color::Black);

    cercle.setPosition((int)x-rayon, (int)y-rayon);
    cercle.setRadius(rayon);
    cercle.setFillColor(Color::White);






    double yb(400), xb(400);


    double coefdir = (yb - y) / (xb - x);
    double angle = atan(coefdir);
    if(x>xb)
    {
        angle = (angle+3.14);
        while(angle > 2*3.14)
        {
            angle -= 2*3.14;
        }
    }
    double angleD = angle*(360/(2*3.14));



    RectangleShape vectorA;
    vectorA.setSize(Vector2f(50, 1));
    vectorA.setPosition(x, y);
    vectorA.setRotation(angleD);

    RectangleShape vectorX;
    vectorX.setSize(Vector2f(50*cos(angle), 1));
    vectorX.setPosition(x, y);
    vectorX.setFillColor(Color::Green);

    RectangleShape vectorY;
    vectorY.setSize(Vector2f(1, 50*sin(angle)));
    vectorY.setPosition(x, y);
    vectorY.setFillColor(Color::Green);


    m_window.draw(base);
    m_window.draw(cercle);
    m_window.draw(vectorA);
    m_window.draw(vectorX);
    m_window.draw(vectorY);



    m_affichageAux->setString("Angle: " + to_string(angleD));
    m_window.draw(*m_affichageAux);

    m_window.display();
}
コード例 #16
0
ファイル: main.cpp プロジェクト: ndt93/Break-Out
	void setup() {
		top.setPosition(0, 0);
		top.setSize(Vector2f(width, borderSize));

		left.setPosition(0, borderSize);
		left.setSize(Vector2f(borderSize, height + borderSize));

		right.setPosition(width - borderSize, borderSize);
		right.setSize(Vector2f(borderSize, height + borderSize));

		bottom.setPosition(0, height + 2*borderSize);
        bottom.setSize(Vector2f(width, borderSize));

		top.setFillColor(Color(100,100,100));
        top.setOutlineColor(Color::Black);
        top.setOutlineThickness(2);
 
        left.setFillColor(Color(100,100,100));
        left.setOutlineColor(Color::Black);
        left.setOutlineThickness(2);
 
        right.setFillColor(Color(100,100,100));
        right.setOutlineColor(Color::Black);
        right.setOutlineThickness(2);
 
        bottom.setFillColor(Color(100,100,100));
        bottom.setOutlineColor(Color::Black);
        bottom.setOutlineThickness(2);

		ball.setPosition(width/2, height - margin);
		ball.setSize(Vector2f(20, 20));
		ball.setFillColor(Color::Green);
		ball.setOutlineColor(Color::Red);
		ball.setOutlineThickness(2);

		player.setSize(Vector2f(90,borderSize));
        player.setPosition(width/2-45, height-margin-borderSize);
        player.setFillColor(Color(0, 122, 245));
        player.setOutlineColor(Color::Green);
        player.setOutlineThickness(3);

		title.setString("Break Out!");
        title.setFont(font);
        title.setCharacterSize(50);
        title.setPosition(width/2-title.getGlobalBounds().width/2,100);
        title.setColor(Color::Blue); 
     
        start.setString("Press any key to start");
        start.setFont(font);
        start.setCharacterSize(30);
        start.setPosition(width/2-start.getGlobalBounds().width/2,400);
        start.setColor(Color::Red);
 
        won.setString("You have won this game.\n\n Congratulations !");
        won.setFont(font);
        won.setCharacterSize(20);
        won.setPosition(width/2-won.getGlobalBounds().width/2,height/2-won.getGlobalBounds().height/2);
        won.setColor(Color::Green);
 
        lost.setString("You have lost this game, \n better luck next time!");
        lost.setFont(font);
        lost.setCharacterSize(20);
        lost.setPosition(width/2-lost.getGlobalBounds().width/2,height/2-lost.getGlobalBounds().height/2);
        lost.setColor(Color::Red);
 
        score.setString("0");
        score.setFont(font);
        score.setCharacterSize(30);
        score.setPosition(width/2 + score.getGlobalBounds().width/2, height-60);
        score.setColor(Color(0,0,100,50));
 
        lives.setString("5");
        lives.setFont(font);
        lives.setCharacterSize(50);
        lives.setPosition(width/2 - lives.getGlobalBounds().width/2, height-60);
        lives.setColor(Color(0,0,100,50));

		fps.setString("0");
        fps.setFont(font);
        fps.setCharacterSize(30);
        fps.setPosition(fps.getGlobalBounds().width/2,height-40);
        fps.setColor(Color(52,0,100,50));
         
        blip=Sound(soundBuffer1);        
        blam=Sound(soundBuffer2);    
        blap=Sound(soundBuffer3);    
        blop=Sound(soundBuffer4);
         
        resetGame();
        gameState=INTRO;
 
        grid.setDimensions(10,6);
        grid.left = borderSize +5;
        grid.top = borderSize + 5;
        grid.width = width - 12;
        grid.height = 250;
        grid.init();
	}
コード例 #17
0
int main()
{
    RenderWindow window(VideoMode(1366, 768), "Justmove");
    sf::Font font;
    font.loadFromFile("arial.ttf");
    Image image;
    image.loadFromFile("arrow.png");
    image.createMaskFromColor(Color(255, 255, 255));
    Texture herotexture;
    herotexture.loadFromImage(image);
    Sprite herosprite;
    herosprite.setTexture(herotexture);
    herosprite.setTextureRect(IntRect(0, 0, 48, 33));
    herosprite.setPosition(250, 250);
    herosprite.setOrigin(0, 17);
    image.create(1270, 720, Color::White);

    RectangleShape rect;
    rect.setSize(Vector2f(250, 70));
    rect.setFillColor(Color::Green);
    rect.setPosition(1100, 50);
    std::string speedS;

    Text speedt;
    speedt.setFont(font);
    speedt.setCharacterSize(50);
    speedt.setColor(Color::Black);
    speedt.setPosition(1105, 55);

    Texture texture;
    Sprite sprite;
    sprite.setTexture(texture);
    Event event;
    Vector2f vect(1, 0);
    float speed = 0.1, ax = 0, ay = 0, angle = 0;
    Clock clock;
    while (window.isOpen())
    {
        float time = clock.getElapsedTime().asMicroseconds();
        clock.restart();
        time = time / 800;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();



        }

        image.setPixel(herosprite.getPosition().x, herosprite.getPosition().y, Color::Black);
        texture.loadFromImage(image);
        sprite.setTexture(texture);
        sprite.setTextureRect(IntRect(0, 0, 1270, 720));
        if (Keyboard::isKeyPressed(Keyboard::W))
            ax = 20.0f;
        else if (Keyboard::isKeyPressed(Keyboard::S))
            ax = -20.0f;
        else
            ax = 0.0f;
        if (Keyboard::isKeyPressed(Keyboard::A))
            ay = -600.0f;
        else if (Keyboard::isKeyPressed(Keyboard::D))
            ay = 600.0f;
        else
            ay = 0.0f;
        speed += ax * time / 1000000;
        angle += time * ay / speed / 1000000;
        vect.x = cos(angle);
        vect.y = sin(angle);
        herosprite.move(speed * vect.x, speed * vect.y);
        herosprite.setRotation(angle * 180 / PI);

        speedS = Convert(speed);
        speedt.setString(speedS);
        window.clear(Color::White);
        window.draw(sprite);
        window.draw(herosprite);
        window.draw(rect);
        window.draw(speedt);
        window.display();


    }
    return 0;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Secret-Asian-Man/sfml
int main()
{
    //-----------------------------
    RenderWindow window; //creates the main window
    window.create(VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "SFML Works!"); //gives the main window attributes such as width, height, and a name
    //-----------------------------

    //-----------------------------
    window.setFramerateLimit(60);//sets frame rate (makes game speed faster/slower)
    //-----------------------------

    //-----------------------------
    RectangleShape mybox; //A rectangle shape
    mybox.setFillColor(Color::Red); //sets color
    mybox.setSize(Vector2f(20,30)/*an xy coordinate using float*/); //sets size
    mybox.setPosition(0,0); //sets position using the upper left corner of the box by default
    //-----------------------------


    //-----------------------------
    while (window.isOpen()) //the almighty gameloop (Keeps game running until gameover)
    {
        Event event; //creates an event, so we have access to it's many wonderful functions
        while (window.pollEvent(event))// event loop (constantly checks for user inputs and queues the actions)
        {
            switch (event.type)// checks the type of the event...
            {
            case Event::Closed: //closed event, triggered by clicking the X button
                window.close(); //closes the window
                break;

                // key pressed
            case Event::KeyPressed: //KeyPressed event, triggered by pressing any key
                switch (event.key.code) //takes in user inputs and performs actions
                {
                case Keyboard::Escape: //if esc button is pressed...
                    window.close();//close the window
                    break;

                case Keyboard::W://if W is pressed...
                    mybox.move(Vector2f(0,-5));//move the box up
                    break;

                case Keyboard::A://if A is pressed...
                    mybox.move(Vector2f(-5,0));//move the box left
                    break;

                case Keyboard::S://if S is pressed...
                    mybox.move(Vector2f(0,5));//move the box down
                    break;

                case Keyboard::D://if D is pressed...
                    mybox.move(Vector2f(5,0));//move the box right
                    break;

                default:
                    break;
                }//end of switch (event.key.code)
                break;

            default:
                break;
            }//end of switch (event.type)
        }//end of while (window.pollEvent(event))


        //~~~~~~~~~~~~~~~
        process();
        //~~~~~~~~~~~~~~~


        //~~~~~~~~~~~~~~~
        window.clear();//clears the screen
        window.draw(mybox);//draws your box shape on the screen (note: invisible unless displayed)
        //window.display();//displays what ever you drew.
        //~~~~~~~~~~~~~~~

    }//end of while (window.isOpen())

    //-----------------------------

}//end of int main()
コード例 #19
0
static inline RectangleShape getRectForCorners( Vector2<T> one, Vector2<T> two ){
	RectangleShape rect;
	rect.setPosition( std::min( one.x, two.x), std::min( one.y, two.y ) );
	rect.setSize( Vector2f( fabs( one.x - two.x ), fabs( one.y - two.y ) ) );
	return rect;
}
コード例 #20
0
void CHighscore::RenderHighscore()
{
    //init the text
	Text text;
	text.setFont(g_pTextures->f_coolsville);
	text.setCharacterSize(35);
	text.setColor(Color(200, 200, 0));

	std::stringstream Stream;
	Stream.str("");

	RectangleShape rect;
	rect.setFillColor(Color(0, 0, 0, 150));

	if (m_mode == -1)
	{
		int y = 100;

		//draw the highscore list
		for (int i = 0; i < 10; i++)
		{
			m_highscoreText[i].setPosition((int)(g_pFramework->GetWindow()->getSize().x / 2 - m_highscoreText[i].getGlobalBounds().width / 2), y);

			rect.setPosition(m_highscoreText[i].getGlobalBounds().left -10, m_highscoreText[i].getGlobalBounds().top-10);
			rect.setSize(Vector2f(m_highscoreText[i].getGlobalBounds().width +20, m_highscoreText[i].getGlobalBounds().height+20));

			g_pFramework->GetRenderWindow()->draw(rect);
			g_pFramework->GetRenderWindow()->draw(m_highscoreText[i]);

			if (m_highscoreText[i].getGlobalBounds().contains(Vector2f(Mouse::getPosition())) && g_pFramework->keyStates.leftMouseUp)
			{
				m_mode = i;
			}

			y += g_pFramework->GetWindow()->getSize().y/12;
			Stream.str("");
		}
	}
	else
	{


		//if no highscore exists
		if (m_highscore[m_mode].m_level == 0)
		{
			Stream << g_pStringContainer->m_Strings[STRING_NO_HIGHSCORE] << endl;
			text.setString(Stream.str());
			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, g_pFramework->GetWindow()->getSize().y / 2 - text.getGlobalBounds().height / 2);

			rect.setPosition(text.getPosition().x - 10, text.getPosition().y - 10);
			rect.setSize(Vector2f(text.getGlobalBounds().width + 20, text.getGlobalBounds().height + 20));

			g_pFramework->GetRenderWindow()->draw(rect);
			g_pFramework->GetRenderWindow()->draw(text);
		}
		else
		{
			//draw the name
			Stream << m_highscore[m_mode].m_name << endl;

			text.setColor(Color(23, 213, 32));
			text.setCharacterSize(40);
			text.setString(Stream.str());
			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, 100);


			rect.setPosition(text.getPosition().x - 10, text.getPosition().y - 10);
			rect.setSize(Vector2f(text.getGlobalBounds().width + 20, text.getGlobalBounds().height + 20));

			g_pFramework->GetRenderWindow()->draw(rect);
			g_pFramework->GetRenderWindow()->draw(text);

			//draw class and level
			Stream.str("");

			Stream << g_pStringContainer->m_Strings[STRING_LEVEL_REACHED] <<" " << m_highscore[m_mode].m_level << endl;
			Stream << g_pStringContainer->m_Strings[STRING_STARTCLASS] << " ";

			switch (m_highscore[m_mode].m_class)
			{
			case(MINER) :
				Stream << g_pStringContainer->m_Strings[STRING_MINER] << endl;
				break;
			case(BUILDER) :
				Stream << g_pStringContainer->m_Strings[STRING_BUILDER] << endl;
				break;
			case(WARRIOR) :
				Stream << g_pStringContainer->m_Strings[STRING_WARRIOR] << endl;
				break;
			case(MAGE) :
				Stream << g_pStringContainer->m_Strings[STRING_MAGE] << endl;
				break;
			default:
				Stream << g_pStringContainer->m_Strings[STRING_CHEATER] << endl << endl;
				break;
			}

			text.setColor(Color(200, 200, 0));
			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, text.getGlobalBounds().top + text.getGlobalBounds().height);
			text.setCharacterSize(35);
			text.setString(Stream.str());
			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, text.getGlobalBounds().top);
			rect.setPosition(text.getPosition().x - 10, text.getPosition().y - 10);
			rect.setSize(Vector2f(text.getGlobalBounds().width + 20, text.getGlobalBounds().height + 20));

			g_pFramework->GetRenderWindow()->draw(rect);
			g_pFramework->GetRenderWindow()->draw(text);

			//draw attributes
			Stream.str("");
			Stream << g_pStringContainer->m_Strings[STRING_HEALTH] <<":                          " << m_highscore[m_mode].m_attributes.maxHealth << endl;
			Stream << g_pStringContainer->m_Strings[STRING_HEALTHREGENERATION] <<":      " << m_highscore[m_mode].m_attributes.healthRegeneration << endl;
			Stream << g_pStringContainer->m_Strings[STRING_MANA] <<":                             " << m_highscore[m_mode].m_attributes.maxMana << endl;
			Stream << g_pStringContainer->m_Strings[STRING_MANAREGENERATION] <<":         " << m_highscore[m_mode].m_attributes.manaRegeneration << endl;
			Stream << g_pStringContainer->m_Strings[STRING_ARMOUR] <<":                         " << m_highscore[m_mode].m_attributes.armour << endl;
			Stream << g_pStringContainer->m_Strings[STRING_STRENGTH] <<":                            " << m_highscore[m_mode].m_attributes.strength << endl;
			Stream << g_pStringContainer->m_Strings[STRING_CRITICALCHANCE] <<":          " << m_highscore[m_mode].m_attributes.criticalChance << endl;
			Stream << g_pStringContainer->m_Strings[STRING_CRITICALDAMAGE] <<":       " << m_highscore[m_mode].m_attributes.criticalDamage << endl;
			Stream << g_pStringContainer->m_Strings[STRING_LUCK] <<":                             " << m_highscore[m_mode].m_attributes.luck << endl;
			Stream << g_pStringContainer->m_Strings[STRING_BREAKINGSPEED] <<": " << m_highscore[m_mode].m_attributes.breakingSpeed << endl;
			Stream << g_pStringContainer->m_Strings[STRING_SPEED] <<":          " << m_highscore[m_mode].m_attributes.speed << endl;

			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, text.getGlobalBounds().top + text.getGlobalBounds().height);
			text.setFont(g_pTextures->f_cents18);
			text.setCharacterSize(40);
			text.setString(Stream.str());
			text.setPosition(g_pFramework->GetWindow()->getSize().x / 2 - text.getGlobalBounds().width / 2, text.getGlobalBounds().top);
			rect.setPosition(text.getPosition().x - 10, text.getPosition().y - 10);
			rect.setSize(Vector2f(text.getGlobalBounds().width + 20, text.getGlobalBounds().height + 20));

			g_pFramework->GetRenderWindow()->draw(rect);
			g_pFramework->GetRenderWindow()->draw(text);

		}
	}
}
コード例 #21
0
ファイル: main.cpp プロジェクト: in0x/go_on_proto
int main(int argc, char** argv)
{
	RenderWindow window(sf::VideoMode(W_WIDTH,W_HEIGHT),"Hello",sf::Style::Close);
		
	View view{ FloatRect{0,0,V_WIDTH,V_HEIGHT} };
	View defaultView = View{ FloatRect{ 0,0, 1600, 1200 } };

	//window.setView(view);

	Physics physics{ {0.f, 9.8f}, 10.f };

	//LightMap lights{view};
	LightMap lights{ defaultView };

	auto playerLight = lights.createLight("../assets/lightmask.png", 400, 370, 3.f);

	//lights.createLight("../assets/lightmask.png", 200, 100, 3.f);

	Clock clock;

	physics.spawnStaticBox(40.f, 60.f, 800.f, 40.f);
	physics.spawnStaticBox(80.f, 110.f, 800.f, 40.f);
	
	auto pPlayerBody = physics.spawnDynamicCircle(3.f, 400.f, 0.f);
	
	Texture tex;
	tex.loadFromFile("../assets/tile.png");
	tex.setSmooth(true);

	Shader blendShader;

	if (!blendShader.loadFromFile("../src/test.frag", Shader::Fragment))
		std::cout << "Failed to load blend fragment shader" << std::endl;

	Texture playerTex;
	playerTex.loadFromFile("../assets/player.png");
	playerTex.setSmooth(true);

	sf::Event ev;

	Texture worldTex;
	worldTex.create(W_WIDTH, W_HEIGHT);
	Sprite displaySprite;

	Font font;
	font.loadFromFile("../assets/kenney_bold.ttf");

	Text framerate;
	framerate.setFont(font);
	framerate.setCharacterSize(40);
	framerate.setPosition(1100, 200);
	framerate.setColor(sf::Color::White);

	while (window.isOpen())
	{
		while (window.pollEvent(ev))
		{
			if (ev.type == Event::Closed)
			{
				window.close();
			}

			if (ev.type == Event::KeyPressed)
			{
				if (ev.key.code == sf::Keyboard::Left)
				{	
					if (pPlayerBody->GetLinearVelocity().x - (MS_X / 100) > -(2 * MS_X / 100))
						pPlayerBody->ApplyForceToCenter({-MS_X, 0.f},true);
					else
						pPlayerBody->ApplyForceToCenter({ -(2 * MS_X / 100) - pPlayerBody->GetLinearVelocity().x , 0.f }, true);
				}

				if (ev.key.code == sf::Keyboard::Right)
				{
					if (pPlayerBody->GetLinearVelocity().x + (MS_X / 100) < (2 * MS_X / 100))
						pPlayerBody->ApplyForceToCenter({ MS_X, 0.f }, true);
					else
						pPlayerBody->ApplyForceToCenter({ (2 * MS_X / 100) - pPlayerBody->GetLinearVelocity().x , 0.f }, true);
				}

				if (ev.key.code == sf::Keyboard::Space)
				{
					if (pPlayerBody->GetLinearVelocity().y + (MS_X / 100)  < (2 * MS_X / 100))
						pPlayerBody->ApplyForceToCenter({ 0.f, -MS_X * 2 }, true);
					//else
						//pPlayerBody->ApplyForceToCenter({ 0.f, (3 * MS_X / 100) - pPlayerBody->GetLinearVelocity().y }, true);
				}
			}

			if (ev.type == Event::JoystickButtonPressed)
			{
				std::cout << ev.joystickButton.button << std::endl;
			}

			if (ev.type == Event::JoystickMoved)
			{
				std::cout << ev.joystickMove.axis << std::endl;
			}
		}

		physics.step(1.f / 30.f);
		
		window.clear();

		auto playerPos = pPlayerBody->GetPosition();
		view.setCenter(SCALE * playerPos.x, SCALE * playerPos.y);
		//window.setView(view);

		auto lightSize = playerLight->getSprite().getTexture()->getSize();

		// 3.f is the player body radius
		playerLight->setPosition(
			playerPos.x * SCALE - lightSize.x - 3.f * SCALE * 2
			, playerPos.y * SCALE - lightSize.y - 3.f * SCALE * 2);

		auto bodyIt = physics.getBodyList();

		//lights.updateView(view);
		lights.render();

		while (bodyIt != nullptr)
		{
			auto pos = bodyIt->GetPosition();

			if (bodyIt->GetType() == b2_dynamicBody)
			{
				CircleShape sprite;
							
				sprite.setTexture(&playerTex);

				auto playerShape = *(b2CircleShape*)(bodyIt->GetFixtureList()->GetShape());

				sprite.setRadius(playerShape.m_radius * SCALE);
				
				sprite.setOrigin(playerShape.m_radius * SCALE, playerShape.m_radius * SCALE);
				
				sprite.setPosition(SCALE * pos.x, SCALE * pos.y);

				sprite.setRotation(bodyIt->GetAngle() * 180 / b2_pi);
				
				window.draw(sprite);
			}

			else // ground
			{
				RectangleShape sprite;
				
				sprite.setSize({800.f, 40.f});
				
				sprite.setOrigin(400, 20);

				sprite.setPosition(pos.x * SCALE, pos.y * SCALE);

				sprite.setRotation(bodyIt->GetAngle() * 180 / b2_pi);

				sprite.setTexture(&tex);

				window.draw(sprite);
			}
			
			bodyIt = bodyIt->GetNext();
		}

		window.draw(Sprite{ lights.getLightMapTexture() }, BlendMultiply);

		float frameTime = 1.f / clock.getElapsedTime().asSeconds();
		clock.restart();
		framerate.setString(std::to_string((int)frameTime) + " fps");

		window.draw(framerate);

		window.display();
	}
}
コード例 #22
0
ファイル: main.cpp プロジェクト: Maxmar1313/Pong-Game
void setMarker(RectangleShape &marker,Vector2f position)
{
	marker.setFillColor(Color::White);
	marker.setPosition(position);
	marker.setSize({ 20,20 });
}
コード例 #23
0
ファイル: Game.cpp プロジェクト: bibixx/The_Light_is_Gone
void Game::gra()
{
	srand(time(0));
	
	
	///////////////////////////////
	Texture tekstura_cel;			//wczytanie tekstur i dzwiêków i tekstów
	tekstura_cel.loadFromFile("data/cel.png");
	Texture tekstura_z;
	tekstura_z.loadFromFile("data/zombie_after_attack_rect.png");
	Texture tekstura;
	tekstura.loadFromFile("data/ground.png");
	Texture tekstura_bl;
	tekstura_bl.loadFromFile("data/blood.png");
	Texture tekstura_zombie_bl;
	tekstura_zombie_bl.loadFromFile("data/zombie_after_attack_rect.png");
	Texture tekstura_zombie_aa;
	tekstura_zombie_aa.loadFromFile("data/zombie_after_attack_rect.png");
	Texture tekstura_zombie_full;
	tekstura_zombie_full.loadFromFile("data/zombie_after_attack_rect.png");
	Texture tekstura_gun;
	tekstura_gun.loadFromFile("data/gun.png");
	Texture tekstura_bullet;
	Texture tekstura_floor;
	tekstura_floor.loadFromFile("data/floor.png");
	Texture tekstura_ak_47;
	tekstura_ak_47.loadFromFile("data/ak_47.png");
	tekstura_bullet.loadFromFile("data/bullet.png");
	Texture tekstura_corps;
	tekstura_corps.loadFromFile("data/corps.png");
	Texture tekstura_ammo;
	tekstura_ammo.loadFromFile("data/ammo_pickup.png");
	Texture tekstura_hp;
	tekstura_hp.loadFromFile("data/hp_pickup.png");
	Texture tekstura_wall;
	tekstura_wall.loadFromFile("data/wall.jpg");
	tekstura_wall.setRepeated(true);
	SoundBuffer buffer, buffer_z;
	buffer_z.loadFromFile("data/hit.wav");
	buffer.loadFromFile("data/shot.wav");
	Sound sound, sound_hit;
	sound.setBuffer(buffer);
	sound_hit.setBuffer(buffer_z);
	SoundBuffer zombie_bite;
	zombie_bite.loadFromFile("data/zombie_bite.wav");
	Sound sound_bite;
	sound_bite.setBuffer(zombie_bite);
	SoundBuffer reload_wav, ammo_out;
	reload_wav.loadFromFile("data/long_reload.wav");
	ammo_out.loadFromFile("data/out_of_ammo.wav");
	SoundBuffer health_wav, ammo_wav;
	health_wav.loadFromFile("data/health.wav");
	ammo_wav.loadFromFile("data/ammo.wav");
	Sound health_collect, ammo_collect;
	health_collect.setBuffer(health_wav);
	ammo_collect.setBuffer(ammo_wav);
	SoundBuffer ak_shot;
	ak_shot.loadFromFile("data/AK_47_shot.wav");
	Sound ak;
	ak.setBuffer(ak_shot);
	Sound sound_reload, sound_ammo_out;
	sound_reload.setBuffer(reload_wav);
	sound_ammo_out.setBuffer(ammo_out);
	Music muzyka;
	muzyka.openFromFile("data/COD4_theme.wav");
	muzyka.setLoop(true);
	muzyka.play();
	
	Font font;
	font.loadFromFile("data/font_UI.ttf");
	Text hp;
	hp.setFont(font);
	hp.setCharacterSize(25);
	hp.setColor(Color(138, 7, 7));
	Text round;
	round.setCharacterSize(25);
	round.setFont(font);
	round.setColor(Color(138, 7, 7));
	Text gun_name;
	gun_name.setCharacterSize(25);
	gun_name.setFont(font);
	gun_name.setColor(Color(138, 7, 7));
	Text bullets_Left;
	bullets_Left.setFont(font);
	bullets_Left.setCharacterSize(25);
	bullets_Left.setColor(Color(138, 7, 7));
	Text licznik_zombie;
	licznik_zombie.setFont(font);
	licznik_zombie.setCharacterSize(25);
	licznik_zombie.setColor(Color(138, 7, 7));
	////////////////////////////////
	
	Sprite celownik;
	celownik.setScale(0.045, 0.045);
	celownik.setTexture(tekstura_cel);
	celownik.setOrigin(celownik.getLocalBounds().width/2.0f, celownik.getLocalBounds().height/ 2.0f);

	RectangleShape sprint_ui;
	sprint_ui.setSize(Vector2f(15 * 5, 15));
	sprint_ui.setFillColor(Color(138, 7, 7));


	/////////////////////////// tablice obiektów
	vector<Blood> tab_bl;
	vector < Bullet > tab; //tablica przechowuj¹ca pociski
	vector <Zombie> tab_z; //zombie
	deque <Vector2f> tab_p;//pozycje gracza z ostatnich 100 klatek
	vector <Corps> tab_corps;
	vector <Ammo_Pickup> tab_am;
	vector <Hp_Pickup> tab_hp;
	

	Sprite map(tekstura);
	tekstura.setRepeated(true);
	map.setTextureRect(IntRect(0, 0, 10000, 10000));
	map.setOrigin(5000,5000);
	map.setPosition(0, 0);
	
	Sprite floor;
	floor.setPosition(-500, -480);
	floor.setTexture(tekstura_floor);
	tekstura_floor.setRepeated(true);
	floor.setTextureRect(IntRect(0, 0, 1000, 980));
	
	vector<RectangleShape> tab_wall;
	for (int i = 0; i < 12; i++)
	{
		RectangleShape wall;
		wall.setFillColor(Color(7, 138, 7, 100));
		
		
		if (i == 0)
		{
			wall.setPosition(-1000, -1000);
			//wall.setFillColor(Color::White);
		}
		else if (i == 1) {
			wall.setPosition(-1000, 1000);
			//wall.setFillColor(Color::Red);
		}
		else if (i == 2) {
			wall.setPosition(-1100, -1000);
			//wall.setFillColor(Color::Cyan);
		}
		else if (i == 3) {
			//wall.setOrigin(100, 0);
			wall.setPosition(1000, -1000);
			//wall.setFillColor(Color::Blue);
		}
		if (i == 0 || i == 1)wall.setSize(Vector2f(2000, 100));
		else if (i == 2 || i == 3)wall.setSize(Vector2f(100, 2100));
		if (i == 4)
		{
			wall.setPosition(-500,-500);

		}
		else if (i == 5)
		{
			wall.setPosition(-520,500);

		}
		else if (i == 6)
		{
			wall.setPosition(-520, -500);

		}
		else if (i == 7)
		{
			wall.setPosition(500, -500);

		}
		if (i == 4 || i == 5)wall.setSize(Vector2f(1020, 20));
		else if (i == 6 || i == 7)wall.setSize(Vector2f(20, 1020));
		
		if (i == 8)
		{
			wall.setPosition(-100, -489);
			wall.setFillColor(Color(138, 7, 7, 150));
		}
		else if (i == 9)
		{
			wall.setPosition(-100, 510);
			wall.setFillColor(Color(138, 7, 7, 150));
		}
		else if (i == 10)
		{
			wall.setPosition(-509, -100);
			wall.setFillColor(Color(138, 7, 7, 150));
		}
		else if (i == 11)
		{
			wall.setPosition(510, -100);
			wall.setFillColor(Color(138, 7, 7,150));
		}
		if (i == 8 || i == 9)wall.setSize(Vector2f(100, 6));
		else if (i == 10 || i == 11)wall.setSize(Vector2f(6, 100));
		if (i == 8 || i == 9 || i == 10 || i == 11)wall.setOrigin(wall.getLocalBounds().width / 2.0f, wall.getLocalBounds().height / 2.0f);

		tab_wall.push_back(wall);

	}
	
	
	Player gracz;
	gracz.body.setPosition(0,0);


	int runda = 1;

	float vx = 0, vy = 0; //prêdkoœæ gracza
	float angle;
	float sprint = 1;

	Clock zombie_player_collisionTimer;
	Clock reload_time;
	Clock zombie_generator_timer;
	Clock zegar;
	Time czas;
	Event event;
	float x, y; //x,y myszy
	okno.setMouseCursorVisible(false);
	int max_zombie_per_round;
	int generated_zombie=0;
	bool generate = true;
	bool menu = false;
	bool canReload = false;
	bool canShoot = true;
	bool Rpressed = false;
	bool isSprint = false;
	bool canSprint = true;
	int zombies_killed_in_round = 0;
	zombie_generator_timer.restart();

	Gun *wsk_gun;
	

	Gun pistol("colt .45", 80.0f,16.0f,2000.0f,2.0f,tekstura_bullet, tekstura_gun,Vector2f(2,2), Vector2f (1,1),gracz.body.getPosition(),0.1);
	Gun ak_47("ak 47", 120.0f, 30.0f, 2800.0f, 2.0f, tekstura_bullet, tekstura_ak_47, Vector2f(2, 2), Vector2f(1, 1), gracz.body.getPosition(),0.08f);
	//view.zoom(1.0f/1.2f);
	//view.zoom(1.0f / 1.2f);
	wsk_gun = &pistol;
	while (!menu)
	{
		//cout << tab_z.size() << " | "<< wsk_gun->bullets_fired.size() <<endl;
		
		gracz.canMoveDown = true;
		gracz.canMoveUP= true;
		gracz.canMoveRight = true;
		gracz.canMoveLeft = true;
		max_zombie_per_round = runda * 4 * 7 ;
		
		if (generated_zombie >= max_zombie_per_round)
		{
			generate = false;
			
		}
		if (!generate&&tab_z.empty())
		{
			zombies_killed_in_round = 0;
			generated_zombie = 0;
			generate = true;
			runda++;

		}
			if (generate && (zombie_generator_timer.getElapsedTime().asSeconds() >= 1.0f)) {
				zombie_generator_timer.restart();
					
						
						if (tab_z.size() <=20)
						{
							generated_zombie += 4;
						zombie_generator(tab_z, Vector2f((tab_wall[0].getPosition().x + rand() % ((int)tab_wall[0].getGlobalBounds().width + 1)), (tab_wall[0].getPosition().y + tab_wall[0].getGlobalBounds().height)), tekstura_z, runda, tab_wall[8].getPosition());
						zombie_generator(tab_z, Vector2f((tab_wall[1].getPosition().x + rand() % ((int)tab_wall[1].getGlobalBounds().width + 1)), (tab_wall[1].getPosition().y + tab_wall[1].getGlobalBounds().height)), tekstura_z, runda, tab_wall[9].getPosition());
						zombie_generator(tab_z, Vector2f((tab_wall[2].getPosition().x + tab_wall[2].getGlobalBounds().width), (tab_wall[2].getPosition().y + rand() % ((int)tab_wall[2].getGlobalBounds().height + 1))), tekstura_z, runda, tab_wall[10].getPosition());
						zombie_generator(tab_z, Vector2f((tab_wall[3].getPosition().x + tab_wall[3].getGlobalBounds().width), (tab_wall[3].getPosition().y + rand() % ((int)tab_wall[3].getGlobalBounds().height + 1))), tekstura_z, runda, tab_wall[11].getPosition());
						
						/*zombie_generator(tab_z, Vector2f((tab_wall[0].getPosition().x + rand() % ((int)tab_wall[0].getGlobalBounds().width + 1)), (tab_wall[0].getPosition().y + tab_wall[0].getGlobalBounds().height)), tekstura_z, runda, Vector2f(0,0));
						zombie_generator(tab_z, Vector2f((tab_wall[1].getPosition().x + rand() % ((int)tab_wall[1].getGlobalBounds().width + 1)), (tab_wall[1].getPosition().y + tab_wall[1].getGlobalBounds().height)), tekstura_z, runda, Vector2f(0,0));
						zombie_generator(tab_z, Vector2f((tab_wall[2].getPosition().x + tab_wall[2].getGlobalBounds().width), (tab_wall[2].getPosition().y + rand() % ((int)tab_wall[2].getGlobalBounds().height + 1))), tekstura_z, runda, Vector2f(0,0));
						zombie_generator(tab_z, Vector2f((tab_wall[3].getPosition().x + tab_wall[3].getGlobalBounds().width), (tab_wall[3].getPosition().y + rand() % ((int)tab_wall[3].getGlobalBounds().height + 1))), tekstura_z, runda, Vector2f(0,0));
*/
						}
						/*else
						{
							generated_zombie += 4;
							zombie_generator(tab_z, Vector2f((tab_wall[4].getPosition().x + rand() % ((int)tab_wall[4].getGlobalBounds().width + 1)), (tab_wall[4].getPosition().y + tab_wall[4].getGlobalBounds().height)), tekstura_z, runda);
							zombie_generator(tab_z, Vector2f((tab_wall[5].getPosition().x + rand() % ((int)tab_wall[5].getGlobalBounds().width + 1)), (tab_wall[5].getPosition().y + tab_wall[5].getGlobalBounds().height)), tekstura_z, runda);
							zombie_generator(tab_z, Vector2f((tab_wall[6].getPosition().x + tab_wall[6].getGlobalBounds().width), (tab_wall[6].getPosition().y + rand() % ((int)tab_wall[6].getGlobalBounds().height + 1))), tekstura_z, runda);
							zombie_generator(tab_z, Vector2f((tab_wall[7].getPosition().x + tab_wall[7].getGlobalBounds().width), (tab_wall[7].getPosition().y + rand() % ((int)tab_wall[7].getGlobalBounds().height + 1))), tekstura_z, runda);
						}*/
					
					
			}
		
			
			
		
		

		view.setCenter(gracz.body.getPosition()); //gracz ca³y czas w centrum widoku
		

		x = (float)Mouse::getPosition(okno).x+view.getCenter().x-1280/2, y = (float)Mouse::getPosition(okno).y+view.getCenter().y-720/2; //zapisanie pozycji myszy wzglêdem lewgo górnego rogu widoku
		
		celownik.setPosition(x, y); //przypisanie pozycji celownika 

		angle = (float)atan2((float)(y - gracz.body.getPosition().y), (float)(x - gracz.body.getPosition().x)) * 180.0f / (float)M_PI - 90.0f; //zapisanie k¹t miêdzy œrodkiem ekranu a pozycj¹ myszy
		gracz.body.setRotation(angle);		//obrócenie gracza w kierunku myszy
		
		cout <<x << " | "<< y << endl;
		
		/////////////////////////////
		if (tab_p.size() != 30)				//wype³nienie tablicy pozycjami gracza z ostatnich stu klatek (czyli 1 sekundy)
		tab_p.push_back(gracz.body.getPosition());

		if (tab_p.size() == 30)
		{	
			tab_p.pop_front();
			tab_p.push_back(gracz.body.getPosition());
		}
		///////////////////////////////
		
		while (okno.pollEvent(event))
		{

			if (event.type == Event::Closed || event.type == Event::KeyPressed &&
				event.key.code == Keyboard::Escape)
				menu = true;
			
			//if (event.type == Event::MouseButtonPressed && Mouse::isButtonPressed(Mouse::Right))//stworzenie zombie i dodanie go do tablicy
			//{

			//	Zombie zombie(x, y, tekstura_z,rand()%51+50, 1+runda);
			//	tab_z.push_back(zombie);

			//}
			if (wsk_gun==&pistol) {
				if (event.type == Event::MouseButtonPressed && Mouse::isButtonPressed(Mouse::Left))//stworzenie pocisku i dodanie go do tablicy
				{
					if (wsk_gun->magazynek == 0)
					{
						sound_ammo_out.play();
						if (wsk_gun->bulletsLeft != 0 && !wsk_gun->reload_demand&& !wsk_gun->reloading)
						{
							sound_reload.play();
							wsk_gun->reload_demand = true;
						}
					}
					else if (!wsk_gun->reloading)
					{
						sound.play();
						wsk_gun->shoot(gracz.body.getPosition());


						wsk_gun->magazynek--;

					}
					else {
						sound_ammo_out.play();
					}
				}
			}
			
		
				if (event.type == Event::MouseButtonPressed && Mouse::isButtonPressed(Mouse::Left) && (wsk_gun->magazynek == 0 || wsk_gun->reloading || wsk_gun->reload_demand))
					sound_ammo_out.play();
			

			
				if (event.type == Event::KeyPressed && event.key.code == Keyboard::R && wsk_gun->bulletsLeft != 0 && wsk_gun->magazynek != wsk_gun->magazynekSize &&!wsk_gun->reloading&& !wsk_gun->reload_demand)
				{
					wsk_gun->reload_demand = true;
					sound_reload.play();
				}

				if (event.type == Event::KeyPressed && event.key.code == Keyboard::Num1)
				{ 
					wsk_gun = &pistol;
					//buffer = wsk_gun->shot;
				}
				if (event.type == Event::KeyPressed && event.key.code == Keyboard::Num2) 
				{
					wsk_gun = &ak_47;
					//buffer = wsk_gun->shot;
				}
			if (event.type == Event::KeyPressed && event.key.code == Keyboard::Up)view.zoom(1.2f);
			if (event.type == Event::KeyPressed && event.key.code == Keyboard::Down)view.zoom(1.0f/1.2f);
			
		}
		/////// strza³ pistoletem
		

		if (wsk_gun != &pistol) {
			if (wsk_gun->fire_timer.getElapsedTime().asSeconds() >= wsk_gun->fireRate) {
				if (Mouse::isButtonPressed(Mouse::Left))//stworzenie pocisku i dodanie go do tablicy
				{
					if (wsk_gun->magazynek == 0)
					{

						if (wsk_gun->bulletsLeft != 0 && !wsk_gun->reload_demand&& !wsk_gun->reloading)
						{
							sound_reload.play();
							wsk_gun->reload_demand = true;
						}
					}
					else if (!wsk_gun->reloading)
					{
					sound.play();
						wsk_gun->shoot(gracz.body.getPosition());


						wsk_gun->magazynek--;


					}
					/*else {
						sound_ammo_out.play();
					}*/
				}
				wsk_gun->fire_timer.restart();
			}
			
		}
		wsk_gun->update(angle, czas, gracz.body.getPosition());

		if(!tab_z.empty())//zombie update
		{
			for (int i = 0; i < tab_z.size(); i++)
				tab_z[i].update(gracz.body.getPosition(), czas,tab_p[0]);
		}
		//if (!tab.empty())//obrócenie zombie w kierunku pozycji gracz z przed sekundy
		//{
		//	for (int i = 0; i < tab.size(); i++)
		//		tab[i].rotate();
		//}
	
		
		
		//////////////////////////////////////kolizja
		
		// kolizja zombie-gracz	
			for (int i = 0; i < tab_z.size(); i++)
			{
				//if(gracz.body.getGlobalBounds().intersects(tab_z[i].body.getGlobalBounds()))
				if (Collision::PixelPerfectTest(gracz.body, tab_z[i].body))
				{
					tab_z[i].collidesWithPlayer = true;
					if ((tab_z[i].body.getPosition().y > gracz.body.getPosition().y >0) || (gracz.body.getPosition().y <tab_z[i].body.getPosition().y <0))
					{
						gracz.canMoveDown = false;
						//gracz.body.move(0, -1);
					}

					if ((gracz.body.getPosition().y >tab_z[i].body.getPosition().y >0) || (tab_z[i].body.getPosition().y < gracz.body.getPosition().y <0))
					{
					
						gracz.canMoveUP = false;
						//gracz.body.move(0, 1);
					}
					
					 if ((tab_z[i].body.getPosition().x > gracz.body.getPosition().x >0)||(gracz.body.getPosition().x <tab_z[i].body.getPosition().x <0))
					{
						gracz.canMoveRight = false;
						//gracz.body.move(-1, 0);
						
					}
					
					 if ((gracz.body.getPosition().x >tab_z[i].body.getPosition().x >0)||(tab_z[i].body.getPosition().x < gracz.body.getPosition().x <0))
					{
						gracz.canMoveLeft = false;
						//gracz.body.move(1, 0);
					}
					
					
					if (zombie_player_collisionTimer.getElapsedTime().asSeconds() >= 0.5) {
						zombie_player_collisionTimer.restart();
					
						sound_bite.play();
						//cout << gracz.healthPoints << endl;
						if (tab_z[i].healthPoints < 3)tab_z[i].body.setTexture(tekstura_zombie_full);
						else tab_z[i].body.setTexture(tekstura_zombie_aa);
						tab_z[i].haveAttacked = true;
						gracz.healthPoints--;
						if (gracz.healthPoints == 0)
						{
							menu = true;
						}
						break;
					}
				}
				else tab_z[i].collidesWithPlayer = false;
			}
		
			// kolizja zombie-zombie
		if (!tab_z.empty())
		{
			for (int i = 0; i < tab_z.size(); i++)
			{
				for (int j = 0; j < tab_z.size(); j++)
				{
					if (i != j)
					{	
						//if (tab_z[j].body.getGlobalBounds().intersects( tab_z[i].body.getGlobalBounds()))
						if (Collision::PixelPerfectTest(tab_z[j].body, tab_z[i].body))
						{
							if (fabs(tab_z[i].body.getPosition().x - gracz.body.getPosition().x) + fabs(tab_z[i].body.getPosition().y - gracz.body.getPosition().y)
				>fabs(tab_z[j].body.getPosition().x - gracz.body.getPosition().x) + fabs(tab_z[j].body.getPosition().y - gracz.body.getPosition().y))
							{
								tab_z[i].collide_parameter = 0;
								tab_z[j].collide_parameter = 1.2;

							}
							else
							{
								tab_z[j].collide_parameter = 0;
								tab_z[i].collide_parameter = 1.2;
							}
							tab_z[i].col_in = true;
							tab_z[j].col_in = true;
							break;
						}


					}

				}
			}


		}
		// kolizja gracz-œciana
		if (tab_wall[4].getGlobalBounds().intersects(gracz.body.getGlobalBounds()))
		{
			gracz.canMoveUP = false;

			sprint = 1;
			//vx = 0;
			//gracz.body.move(0, 1);
			//gracz.canMoveUP = true;
		}
	
		if (tab_wall[5].getGlobalBounds().intersects(gracz.body.getGlobalBounds()))
		{
			sprint = 1;
			gracz.canMoveDown = false;
			//vx = 0;
			//gracz.body.move(0, -1); 
			//gracz.canMoveDown = true;
		}
	 
		if (tab_wall[6].getGlobalBounds().intersects(gracz.body.getGlobalBounds()))
		{
			sprint = 1;
			gracz.canMoveLeft = false;
			//vy = 0;
			//gracz.body.move(1, 0);
			//gracz.canMoveRight = true;
		}
		  
		if (tab_wall[7].getGlobalBounds().intersects(gracz.body.getGlobalBounds()))
		{
			sprint = 1;
			gracz.canMoveRight= false;
			//vy = 0;
			//gracz.body.move(-1, 0);
			//gracz.canMoveLeft = true;
		}
		 

		
		///////////kolizja zombie pocisk
		
			if (!tab_z.empty() && !wsk_gun->bullets_fired.empty())				//zniszczenie pocisku i zombie w przypadku kolizji
			{
				for (int i = 0; i < wsk_gun->bullets_fired.size(); i++)
				{
					for (int j = 0; j < tab_z.size(); j++)
					{
						if (wsk_gun->bullets_fired[i].body.getGlobalBounds().intersects(tab_z[j].body.getGlobalBounds()))
						{
							sound_hit.play();

							bullet_destroy(wsk_gun->bullets_fired, i);

							Blood krew(tekstura_bl, tab_z[j].body.getPosition());
							krew.body.setRotation((rand() % 360) + 1);
							tab_bl.push_back(krew);

							tab_z[j].healthPoints--;
							if (tab_z[j].healthPoints == 1)
							{
								tab_z[j].setSpeed(80.0f);
								if (tab_z[j].haveAttacked == true)tab_z[j].body.setTexture(tekstura_zombie_full);
								else tab_z[j].body.setTexture(tekstura_zombie_bl);
							}
							if (tab_z[j].healthPoints == 0)
							{	//œmieræ zombie
								Corps corpses(tekstura_corps, tab_z[j].body.getPosition(), tab_z[j].rotate_angle);
								tab_corps.push_back(corpses);
								if (tab_z[j].isInside)
								{
									Ammo_Pickup am(tekstura_ammo, tab_z[j].body.getPosition());
									Hp_Pickup hp(tekstura_hp, tab_z[j].body.getPosition());
									switch (rand() % 10)
									{
									case 0:
										tab_am.push_back(am);
										break;
									case 1:
										tab_am.push_back(am);
										break;
							


									case 5:
										if (gracz.healthPoints < 5)tab_hp.push_back(hp);
										break;

									}
								}
								tab_z[j] = tab_z[tab_z.size() - 1];
								tab_z.pop_back();
								zombies_killed_in_round++;

							}

							break;
						}


					}
				}
			}
		
		//kolizja gracz-ammo_pickup
		for (int i = 0; i < tab_am.size(); i++)
		{
			if (gracz.body.getGlobalBounds().intersects(tab_am[i].body.getGlobalBounds()))
			{	
				ammo_collect.play();
				
					wsk_gun->bulletsLeft += tab_am[i].add_ammo;
				
				ammo_destroy(tab_am, i);
			}
		}

		//kolizja gracz-hp_pickup
		for (int i = 0; i < tab_hp.size(); i++)
		{
			if (gracz.body.getGlobalBounds().intersects(tab_hp[i].body.getGlobalBounds()))
			{
				
				if (gracz.healthPoints + tab_hp[i].add_hp <= 5)
				{
					health_collect.play();
					gracz.healthPoints += tab_hp[i].add_hp;
					hp_destroy(tab_hp, i);
				}
			}
		}
		////////////////////////////////////////
		for (int j = 4; j < tab_wall.size()-4;j++)
		for (int i = 0; i < wsk_gun->bullets_fired.size(); i++)
		{

			if (wsk_gun->bullets_fired[i].body.getGlobalBounds().intersects(tab_wall[j].getGlobalBounds()))
				bullet_destroy(wsk_gun->bullets_fired, i);
		}
		for (int j = 8; j < tab_wall.size(); j++)
			for (int i = 0; i < tab_z.size(); i++)
				if (tab_z[i].body.getGlobalBounds().intersects(tab_wall[j].getGlobalBounds()))tab_z[i].isInside = true;

			for (int i = 0; i < wsk_gun->bullets_fired.size(); i++)
			{
				if (wsk_gun->bullets_fired[i].onCreate_clock.getElapsedTime().asSeconds() >= wsk_gun->bullets_fired[i].lifeTime)
				{
					bullet_destroy(wsk_gun->bullets_fired, i);
				}
			}
		
		for (int i = 0; i < tab_bl.size(); i++)
		{
			if (tab_bl[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_bl[i].lifeTime)
			{
				blood_destroy(tab_bl, i);
			}
		}
		for (int i = 0; i < tab_corps.size(); i++)
		{
			if (tab_corps[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_corps[i].lifeTime)
			{
				corps_destroy(tab_corps, i);
			}
		}
		
		for(int i = 0; i < tab_am.size(); i++)
		{
			if (tab_am[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_am[i].lifeTime)
			{
				ammo_destroy(tab_am, i);
			}
		}
		
		for (int i = 0; i < tab_hp.size(); i++)
		{
			if (tab_hp[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_hp[i].lifeTime)
			{
				hp_destroy(tab_hp, i);
			}
		}
		
		///////////////////////////////////////////
		 
			interfejs(gracz.healthPoints, wsk_gun->bulletsLeft, hp, bullets_Left, view.getCenter(), wsk_gun->magazynek, runda, round, max_zombie_per_round - zombies_killed_in_round, licznik_zombie, 
				gun_name, wsk_gun->name, sprint_ui, isSprint&&(tab_p[0]!=gracz.body.getPosition()), czas);
		
		okno.setView(view);
		okno.clear();
		//cout << "Up: " << gracz.canMoveUP << " | Down: " << gracz.canMoveDown << " | Left: " << gracz.canMoveLeft << " | Right: " << gracz.canMoveRight << endl;
		/////////////////////////////////////////////////////
		gracz.input(vx, vy);
		if (Keyboard::isKeyPressed(Keyboard::LShift) && canSprint)
		{
			if (sprint_ui.getSize().x < 1) {
				canSprint = false;
			}
			sprint = 1.5;
			isSprint = true;
		}
		else
		{
			if (sprint_ui.getSize().x >15) {
				canSprint = true;
			}
			sprint = 1;
			isSprint = false;
		}
		//////////////////////////////////////
		//	ruch //

		
		gracz.ruch(czas, vx, vy, sprint);
	

		/*if (!tab_z.empty())
		{

			for (int i = 0; i < tab_z.size(); i++)
			{

				tab_z[i].ruch(tab_p[0], czas);
			}
		}*/

		
		////////////////////////////////
		okno.draw(map);		
		//rysowanie
	
		okno.draw(floor);
			if (!wsk_gun->bullets_fired.empty())
			{
				for (int i = 0; i <wsk_gun->bullets_fired.size(); i++)
					if (!gracz.body.getGlobalBounds().intersects(wsk_gun->bullets_fired[i].body.getGlobalBounds()))
					okno.draw(wsk_gun->bullets_fired[i].body);
			}
		
		if (!tab_bl.empty())
		{
			for (int i = 0; i < tab_bl.size(); i++)
			{
				
				okno.draw(tab_bl[i].body);
				//okno.draw(tab_bl[i].rect);
			}
		}
		if (!tab_corps.empty())
		{
			for (int i = 0; i < tab_corps.size(); i++)
				okno.draw(tab_corps[i].body);
		}
		if (!tab_am.empty())
		{

			for (int i = 0; i < tab_am.size(); i++)
			{
				if(tab_am[i].onCreate_clock.getElapsedTime().asSeconds() < tab_am[i].lifeTime-8.0f)
				okno.draw(tab_am[i].body);
				if (tab_am[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_am[i].lifeTime - 8.0f)
				{
					if (tab_am[i].onCreate_clock.getElapsedTime().asMilliseconds() % 500 >= 0 && tab_am[i].onCreate_clock.getElapsedTime().asMilliseconds() % 500 <= 125) {
						//nie rysij
					}
					else okno.draw(tab_am[i].body);

				}
			}
		}
		if (!tab_hp.empty())
		{

			for (int i = 0; i < tab_hp.size(); i++)
			{
				if (tab_hp[i].onCreate_clock.getElapsedTime().asSeconds() < tab_hp[i].lifeTime - 8.0f)
					okno.draw(tab_hp[i].body);
				if (tab_hp[i].onCreate_clock.getElapsedTime().asSeconds() >= tab_hp[i].lifeTime - 8.0f)
				{
					if (tab_hp[i].onCreate_clock.getElapsedTime().asMilliseconds() % 500 >= 0 && tab_hp[i].onCreate_clock.getElapsedTime().asMilliseconds() % 500 <= 125) {
						//nie rysij
					}
					else okno.draw(tab_hp[i].body);

				}
			}
		}
		if (!tab_z.empty())
		{
			for (int i = 0; i < tab_z.size(); i++)
				okno.draw(tab_z[i].body);
		}
		for (int i = 4; i < tab_wall.size(); i++)
		{
			okno.draw(tab_wall[i]);
		}
		okno.draw(celownik);
		okno.draw(gracz.body);
		//okno.draw(gracz.point);
		okno.draw(wsk_gun->body);

		okno.draw(hp);
		okno.draw(bullets_Left);
		okno.draw(round);
		okno.draw(licznik_zombie);
		okno.draw(gun_name);
		okno.draw(sprint_ui);
		//////////////////////////////////

		View view = okno.getDefaultView();
		okno.display();
		
		czas = zegar.getElapsedTime();
		zegar.restart();

	}
	


}
コード例 #24
0
 Brick(float mX, float mY) {
     shape.setPosition(mX, mY);
     shape.setSize({blockWidth, blockHeight});
     shape.setOrigin(blockWidth/2.f, blockHeight/2.f);
     shape.setFillColor(Color::Red);
 }
コード例 #25
0
ファイル: game.cpp プロジェクト: jbhoopesphd/circuit_game
	Board(float bX, float bY)
	{
		cboard.setSize(Vector2f(300, 400));
		cboard.setFillColor(Color::White);
		cboard.setPosition(bX, bY);
	}
コード例 #26
0
 Paddle(float mX, float mY) {
     shape.setPosition(mX, mY);
     shape.setSize({paddleWidth, paddleHeight});
     shape.setFillColor(Color::Green);
     shape.setOrigin(paddleWidth/2.f, paddleHeight/2.f);
 }