Beispiel #1
0
void * init () 
{
    sf::Clock sclock;
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    char * font_path;
    find_font( &font_path );

    if (!MyFont.loadFromFile(font_path)) 
    {
        printf("error loading font\n");
    }

    setup();
    draw_hud();

    for (int i = 1; i < 6; i++)
        add_slot(i);

    while (window.isOpen()) 
    {
        update(window, sclock);
    }
    return NULL;
}
Beispiel #2
0
void Scoring::Initialize()
{
	font.loadFromFile("./Resources/Fonts/jokerman.ttf");
	points_graphics.setFont(font);
	points_graphics.setCharacterSize(24);
	points_graphics.setString("0");
}
Beispiel #3
0
	Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
	{
		ball.setFillColor(sf::Color::Cyan);
		ball.setPosition(100.0, 100.0);
		ball.setRadius(10.f);

		p1Paddle.setFillColor(sf::Color::Green);
		p1Paddle.setPosition(10.0, 100.0);
		p1Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p2Paddle.setFillColor(sf::Color::Red);
		p2Paddle.setPosition(580.0, 100.0);
		p2Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p1MovingUp = false;
		p1MovingDown = false;
		p2MovingUp = false;
		p2MovingDown = false;

		ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
		font.loadFromFile("arial.ttf");

		p1ScoreText.setPosition(150, 10);
		p1ScoreText.setFont(font);
		p1ScoreText.setString(std::to_string(p1Score));
		p1ScoreText.setColor(sf::Color::Red);
		p1ScoreText.setCharacterSize(24);

		p2ScoreText.setPosition(450, 10);
		p2ScoreText.setFont(font);
		p2ScoreText.setString(std::to_string(p2Score));
		p2ScoreText.setColor(sf::Color::Red);
		p2ScoreText.setCharacterSize(24);
	}
Beispiel #4
0
    void init() {
        this->restart();
        // RectangleShapes
        sf::Vector2f unit(unit_w, unit_h);
        stone_view = sf::RectangleShape(unit);
        stone_view.setFillColor(sf::Color(255, 81, 68));
        body_view = sf::RectangleShape(unit);
        body_view.setFillColor(sf::Color(0, 204, 255));
        food_view = sf::RectangleShape(unit);
        food_view.setFillColor(sf::Color(19, 169, 136));

        // font & msg
        if (!font.loadFromFile("Inconsolata-Bold.ttf")) {
            puts("fonts loading error!");
            this->close();
        }
        msg1.setFont(font);
        msg1.setColor(sf::Color::White);
        msg1.setCharacterSize(50);
        msg1.setPosition(80, 100);
        msg2.setFont(font);
        msg2.setColor(sf::Color::White);
        msg2.setCharacterSize(25);
        msg2.setString("Press <Enter> to Replay");
        msg2.setPosition(60, 250);
    }
Beispiel #5
0
  bool FontHandler::LoadFromFile(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // Retrieve the filename for this asset
    std::string anFilename = GetFilename(theAssetID);

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromFile(anFilename);
#else
      anResult = theAsset.loadFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
Beispiel #6
0
	virtual void init()
	
	
	{
		dt=0;
		select_switch = 0.2;
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
	//	darken = sf::RectangleShape(sf::Vector2f(800,400));
		
//sfx
if (!buffer.loadFromFile("sfx/Blip 007.wav"))

{
     //error
}
blip.setBuffer(buffer);


		if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl;

		t**s.setTexture(title);
		t**s.setOrigin(50,8);
		t**s.setScale(sf::Vector2f(3,3));
		t**s.setPosition(400,100);
		
		sf::FloatRect tempt ;
		
		for(int i =0 ; i<4;i++)
		{
			selector[i].setFont(standard_font);
			selector[i].setCharacterSize(28);
			 
		
		// dla centrowania obiektow
		
			tempt = selector[i].getGlobalBounds();
			selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
			
			selector[i].setPosition(350,150+30*i);
		}
		
		selector[0].setString("Start game");
		selector[1].setString("Info");
		selector[2].setString("Highscores");
		selector[3].setString("Exit");
		
		
		selector[0].setColor(sf::Color(0,127,127));
		
		timer.restart();
		
		};
Beispiel #7
0
	bool initalize(sf::RenderWindow*& rw){
		//renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
		renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1280, 720, 32), "NMLB");
		drawCalls = frameCount = 0;

		cameraX = TARGET_WIDTH / 2;
		cameraY = TARGET_HEIGHT / 2;
		cameraZ = 1.0f;

		return menuFont.loadFromFile(c::fontDir.child("Arial.ttf").path());
	}
Beispiel #8
0
int WindowCreateThing::load() {
    if(!font.loadFromFile("arial.ttf")){
        std::cerr << "Error loading arial.png" << std::endl;
        return (-1);
    }

    if(!textureFolder.loadFromFile("folder.png")) {
        std::cerr << "Error loading folder.png" << std::endl;
        return (-1);
    }
    return 0;
}
Beispiel #9
0
	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 


		tit.setString("Made by");

		explain.setFont(standard_font);
		explain.setString("Just a bored slacker");
		explain.setCharacterSize(36);
		explain.setPosition(260,320);

		tit.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));

		
		tit.setPosition(400,120);


if (!tex.loadFromFile("gfx/jabslogo.png"))
	
	{
		std::cout<<"Fuckup"<<std::endl;
		}

		spr.setTexture(tex);
		spr.setPosition(334,144);

		
		timer.restart();
		
		};
	void set_font()
	{
		
		assert(m_file_name != "");
		
		if (!m_font.loadFromFile(m_file_name))
		{
				
			std::cout << m_file_name << " not found!\n";
				
		}
		 
	}
Beispiel #11
0
	// Constructeur & destructeur
	Observer(const sf::Vector2f& center)
	{
		//sf::Font font;
		assert(_font.loadFromFile("vera.ttf") == true);
		_text.setColor(sf::Color::White);
		_text.setFont(_font);
		_text.setCharacterSize(50);
		_text.setStyle(sf::Text::Italic);
		_border.setPosition(center);
		_border.setOutlineColor(sf::Color::White);
		_border.setOutlineThickness(2.0);
		_border.setFillColor(sf::Color::Transparent);
	}
void initTexts()
{
    if (!font.loadFromFile("arial.ttf"))cout << "error";
    endText.setFont(font);
    endText.setString("Game Over");
    endText.setCharacterSize(50);
    endText.setColor(sf::Color( 156, 39, 176));
    endText.setPosition(SIZE/2-100,SIZE/2-100);
    scoreText.setFont(font);
    scoreText.setCharacterSize(50);
    scoreText.setColor(sf::Color(255,255,255));
    scoreText.setPosition(SIZE/2-200,SIZE/2);
}
Beispiel #13
0
	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 
		score.setFont(standard_font); 

		std::stringstream ss;
		ss << your_score;
		std::string str = ss.str();
		
		
		tit.setString("Congrats! You beat the game\nIt took you:");
		
		score.setString(str + " seconds");


		tit.setCharacterSize(24);
		score.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();
		sf::FloatRect tempr = score.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
		score.setOrigin(sf::Vector2f(tempr.width/2,tempr.height/2));

		
		tit.setPosition(400,150);
		score.setPosition(400,200);

		score.setColor(sf::Color(0,127,127));

		
		timer.restart();
		
		};
	sf::Font &GetDefaultFont()
	{
		if (init)
		{
			bool success = defFont.loadFromFile(JOUST_FONT);
			if (!success)
			{
				printf("Failed to load font %s\n", JOUST_FONT);
				exit(1);
			}
			init = false;
		}
		return defFont;
	}
Beispiel #15
0
void Presentation::drawIntro(sf::RenderWindow &window){
     sf::Font ibm;
    sf::Font font;
    if (!ibm.loadFromFile("ibm.ttf")) {
        std::cerr << "Error loading ibm.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textTitleIntro;
    textTitleIntro.setFont(ibm);
    textTitleIntro.setString("HELLO");
    textTitleIntro.setCharacterSize(100);
    textTitleIntro.setColor(sf::Color::White);
    textTitleIntro.setOrigin(textTitleIntro.getLocalBounds().left+textTitleIntro.getLocalBounds().width/2.0f, textTitleIntro.getLocalBounds().top+textTitleIntro.getLocalBounds().height/2.0f);
    textTitleIntro.setPosition(window.getSize().x/2, textTitleIntro.getLocalBounds().height/1.5f);


   window.draw(textTitleIntro);


    TCHAR nameBuf[MAX_COMPUTERNAME_LENGTH + 2];
    DWORD nameBufSize;

    nameBufSize = sizeof nameBuf - 1;
    if (GetUserName(nameBuf, &nameBufSize) == TRUE) {
    //_tprintf(_T("Your computer name is %s\n"), nameBuf);
    }
    //std::cout << nameBuf << std::endl;
    strcpy (str,"HELLO (C) ");
    strcat (str,nameBuf);

    if (!font.loadFromFile("arial.ttf")) {
        std::cerr << "Error loading arial.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textSubTitleIntro;
    textSubTitleIntro.setFont(font);
    textSubTitleIntro.setString(str);
    textSubTitleIntro.setCharacterSize(25);
    textSubTitleIntro.setColor(sf::Color::White);
    textSubTitleIntro.setPosition(20, window.getSize().y/2);
    window.draw(textSubTitleIntro);

    sf::Text textContinueIntro;
    textContinueIntro.setFont(font);
    textContinueIntro.setString("Space to continue or Esc to cancel");
    textContinueIntro.setCharacterSize(25);
    textContinueIntro.setColor(sf::Color::White);
    textContinueIntro.setPosition(20, window.getSize().y/3);
    window.draw(textContinueIntro);
}
Beispiel #16
0
void init()
{
    int major,minor;
    v.getOpenGLVersion(&major,&minor);

    cout <<"Opengl version supported : "<<major<<"."<<minor<<endl;
    v.getGLSLVersion(&major,&minor);
    cout << "GLSL version supported : "<<major<<"."<<minor << endl;
    //delegate to our view class to do all the initializing
    v.initialize();

	if (!font.loadFromFile("resources/GARA.ttf"))
		return;

}
Beispiel #17
0
	int init()
	{
		scrw = 800; scrh = 600;
		mouse_wheel = 0;
		
		window = new sf::RenderWindow(sf::VideoMode(scrw, scrh), "thing");
		window->setVerticalSyncEnabled(true);
		
		view = new sf::View(sf::FloatRect(-40, 30, 80, -60));
		noview = new sf::View(sf::FloatRect(0, 0, scrw, scrh));
		window->setView(*view);
		
		arial.loadFromFile("arial.ttf");
		
		return 0;
	}
Beispiel #18
0
	void init_char_width(){
		if (!PTSANS.loadFromFile("PTN57F.ttf" )) return;
		PTSANS_loaded = true;

		string tq;
		
		int tmp = log_string.getPosition().x;
		
		for( int i = 255; i--; ){
			tq = (char) i;
			log_string.setString( tq );
			char_width[i] = log_string.findCharacterPos( 1 ).x - tmp;
		}


	}
Beispiel #19
0
int main()
{
	window.create(sf::VideoMode(800, 600), "Breakfree");
	window.setVerticalSyncEnabled(true);
	//, sf::Style::Close|sf::Style::Titlebar);
	
	if (!font.loadFromFile("Nirmala.ttf"))
		return EXIT_FAILURE;

	Levels lv;
	Paddle pad;
	InputManager input;
	
	while (window.isOpen())
	{
		switch (level)
		{
		case 0:
			lv.loadLv0();
			break;
		}
		while (playing)
		{
			input.ExecuteEvents(window);
			
			pad.Update();
			

			window.clear(); // ------draw graphics here-------

			sf::Text text("Score: " + std::to_string(score), font, 20);
			text.setPosition(660, 220);
			window.draw(text);

			lv.Draw(window);

			window.draw(pad.sprite);
			window.draw(pad.ball);

			window.display(); // -----------------------
		}
	}

	return 0;
}
Beispiel #20
0
        hud()
        {
            tex_paskaHp[ 0 ].loadFromFile( "gfx/pasek_hpTlo.png" );
            tex_paskaHp[ 1 ].loadFromFile( "gfx/pasek_hp.png" );
            tex_paskaBonusu[ 0 ].loadFromFile( "gfx/pasek_bonusTlo.png" );
            tex_paskaBonusu[ 1 ].loadFromFile( "gfx/pasek_bonus.png" );
            spr_paskaHp.setTexture( tex_paskaHp[ 0 ] );
            spr_paskaBonusu.setTexture( tex_paskaBonusu[ 0 ] );
            tex_tla.loadFromFile( "gfx/tlo0.png" );
            czcionka.loadFromFile( "font/Barme Reczny.ttf" );
            tekst.setFont( czcionka );
            tekst.setCharacterSize( 18 );
            timer[ 0 ] = 0;
            timer[ 1 ] = 0;
            typ_bonusu = 0;
            alphaPaskaBonusu = 0.0001;
//            spr_paskaBonusu.setColor( sf::Color( 255, 255, 255, alphaPaskaBonusu ) );
        }
void TextBox::Setup(int visible, int charSize, int width, sf::Vector2f screenPos)
{
	_numVisible = visible;

	sf::Vector2f offset(2.0f, 2.0f);

	_font.loadFromFile("arial.ttf");
	_content.setFont(_font);
	_content.setString("");
	_content.setCharacterSize(charSize);
	_content.setColor(sf::Color::White);
	_content.setPosition(screenPos + offset);

	auto backdropHeight = visible * (charSize * 1.2f);
	_backdrop.setSize(sf::Vector2f(width, backdropHeight));
	_backdrop.setFillColor(sf::Color(90, 90, 90, 90));
	_backdrop.setPosition(screenPos);
}
void rendering::render_time(sf::RenderWindow& screen,const GameInfo& stats)
{
   static sf::Text text;
   static sf::Font f;

   f.loadFromFile("../data/Font/Loma.ttf");

   text.setFont(f);
   text.setColor(sf::Color::Red);
   text.setCharacterSize(24);
   text.setPosition(700,100);
   text.setString(stats.GetFormattedElapsed());
   screen.draw(text);

   text.setString(std::to_string(stats.getFps()));
   text.setPosition(700,125);
   screen.draw(text);
}
Beispiel #23
0
menu_system::menu_system()
{
    font.loadFromFile("Res/VeraMono.ttf");

    ui_box start;
    start.pos = {0.5f, 0.5f};
    start.dim = {100, 100};
    start.label = "Start";
    start.font_size = 60;
    start.callback = start_game;

    sf::Text text(start.label, font, start.font_size);

    float pad = 1.2f;

    start.dim = (vec2f){text.getGlobalBounds().width, text.getGlobalBounds().height} * pad;

    ui_elements.push_back(start);
}
void setAll(int& x,int& y,int& xBlock,int& yBlock)
{
	x = 375; 
	y = 250;
	
	if(!font.loadFromFile("ethnocentric rg.ttf"))
	{
		//error...
	};

	text = convertInt(score1);
	score.setString(text);
	score.setFont(font);
	score.setCharacterSize(24);
	score.setColor(sf::Color(60,60,255));
	
	square.setPosition(x,y);
	xBlock = 100;
	yBlock = 100;
}
Beispiel #25
0
  ThermalScannerApp()
    : readingsTree(
        0.0, 0.0, 360.0, thermalObservedPitchRange, 4
      )
    , scannerThread(&ThermalScannerApp::scannerThreadFunc, this)
    , httpdThread(&ThermalScannerApp::httpdThreadFunc, this)
    , wsdThread(&ThermalScannerApp::wsdThreadFunc, this)
  {
    isRunning = true;

    viewPitch = thermalViewPitchRange/2.0;
    viewYaw = 180.0;
    isViewLockedToDeviceOrientation = false;

    prevThermalUpdateTime = 0.0;

    viewImage.create(windowWidth, windowHeight);

    for(int i = 0; i < 0; i++) {
      RectTree<SensorReading>::Rect rect(
        (double)rand()/(double)RAND_MAX*360.0,
        (double)rand()/(double)RAND_MAX*thermalObservedPitchRange,
        (double)rand()/(double)RAND_MAX*50.0,
        (double)rand()/(double)RAND_MAX*50.0,
        SensorReading((double)rand()/(double)RAND_MAX*30.0, 5)
      );
      readingsTree.add(rect);
    }

    if(!font.loadFromFile("Arial Black.ttf")) {
      throw std::runtime_error("Unable to load font!");
    }

    sensorUpdateDelay = 35;
    scannerThread.launch();

    httpdThread.launch();

    //wsdThread.launch();
    wsdThread.launch();
  }
Beispiel #26
0
	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 
		subtit.setFont(standard_font); 


		tit.setString(title);
		subtit.setString(subtitle);

		tit.setCharacterSize(24);
		subtit.setCharacterSize(18);
		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();
		sf::FloatRect temps = subtit.getGlobalBounds();
		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
		subtit.setOrigin(sf::Vector2f(temps.width/2,temps.height/2));
		
		tit.setPosition(400,150);
		subtit.setPosition(400,180);
		
		timer.restart();
		
		};
Beispiel #27
0
	/*
		PRIVATE function are not supposed to be called from outside VisualNovel namespace
		even though it's accessible from global.
		it can lead to errors if called
	*/
	void Init(){
		//get the image for the text's background
		log_background = get_image( "resource/LogBackground.png" );

		//set the volume to the default global volume
		SoundFx.setVolume( MUSIC_VOLUME ); 
		
		static bool loaded = false;
		if( !loaded ) //to prevent double calling
		{
			font_display.loadFromFile( "resource/PTN57F.ttf" );

			log_text_display.setFont( font_display );
			log_text_display.setCharacterSize( 24 );
			log_text_display.setColor( sf::Color( 255, 255, 255 ) );
			log_text_display.setPosition( log_x + log_padding_x, log_y + log_padding_y );

			log_name_display.setFont( font_display );
			log_name_display.setCharacterSize( 40 );
			log_name_display.setColor( sf::Color( 255, 255, 255 ) );
			log_name_display.setPosition( log_x + log_padding_x, log_y - log_to_name_y - 40 );
		}
	}
Beispiel #28
0
	int log_setup_1(){
		//Load Font
		if( PTSANS_loaded == false ){
			if (!PTSANS.loadFromFile("PTN57F.ttf")) return -1;
			PTSANS_loaded = true;
		}

		texture_3.loadFromFile( "Temp_log.png" );

		//Setup Strings
		log_string.setFont( PTSANS );
		log_string.setCharacterSize(24);
		log_string.setColor( sf::Color(255, 255, 255) );
		log_string.setPosition(90.f, 600.f);

		log_name.setFont( PTSANS );
		log_name.setCharacterSize(40);
		log_name.setColor( sf::Color(255, 255, 255) );
		log_name.setPosition(90.f, 535.f);

		log_back.setTexture( texture_3, false );
		log_back.setPosition( 0.f, 580.f );

	}
void setup(sf::RenderWindow& s, sf::Event& e, sf::Text& t, sf::Font& tf, sf::Text& v, tgui::ListBox::Ptr& res, tgui::ListBox::Ptr& mode, tgui::EditBox::Ptr& c1, tgui::EditBox::Ptr& c2, tgui::Button::Ptr& b, tgui::Gui& sg)
{
	tf.loadFromFile("sansation.ttf");

	//WINDOW
	s.setFramerateLimit(10);

	//TITLE
	t.setFont(tf);
	t.setPosition(-5, 0);
	t.setStyle(sf::Text::Underlined);
	t.setString(" GRAVITY SIMULATOR ");
	t.setCharacterSize(30);

	//VERSIONTEXT
	v.setFont(tf);
	v.setColor(sf::Color(51, 255, 255));
	v.setPosition(247, 33);
	v.setString("v1.0");
	v.setCharacterSize(25);

	//GUI
	sg.setFont(tf);
	sg.add(res);
	sg.add(mode);
	sg.add(c1);
	sg.add(c2);
	sg.add(b);

	//VIDEOMODE
	mode->setScrollbar(nullptr);
	mode->setPosition(20, 80);
	mode->setItemHeight(15);
	mode->setSize(95, 30);
	mode->setTextSize(15);
	mode->addItem("FULLSCREEN");
	mode->addItem("WINDOWED");
	mode->setSelectedItemByIndex(0);

	//RESOLUTIONS
	res->setScrollbar(nullptr);
	res->setPosition(20, 115);
	res->setItemHeight(15);
	res->setTextSize(15);

	res->addItem("2560 x 1440");
	res->addItem("1920 x 1080");
	res->addItem("1366 x 768");
	res->addItem("CUSTOM");
	res->setSize(95, res->getItemCount() * 15);

	//CUSTOM RESOLUTION
	c1->setDefaultText("X");
	c1->setPosition(125, 140);
	c1->setSize(50, 15);
	c1->setTextSize(15);
	c1->setMaximumCharacters(4);
	
	c2->setDefaultText("Y");
	c2->setPosition(125, 160);
	c2->setSize(50, 15);
	c2->setTextSize(15);
	c2->setMaximumCharacters(4);

	//STARTBUTTON
	b->setPosition(185, 140);
	b->setSize(95, 35);
	b->setText("START");
	b->setTextSize(15);
	b->connect("pressed", start, res, mode, c1, c2);

}
Beispiel #30
0
int main()
{
	font.loadFromFile("font.ttf");
	sf::Clock fclock; // frame fclock
	sf::Clock clock; // accumulative clock

	sf::Text fps {"", font, 12};
	fps.setPosition(5.f, 5.f);
	std::ostringstream fps_s;

	sf::Text winner {"", font, 24};
	std::ostringstream win_s;

	bool paused {true};

	sf::RenderWindow window
	{
		sf::VideoMode(800, 600, 32),
		"Light Cycles"
	};
	window.setVerticalSyncEnabled(false);
	window.setFramerateLimit(120);

	sf::View view (window.getView());

	sf::Event event;

	sf::RectangleShape bounds {v2f(790.f, 590.f)};
	bounds.setPosition(5.f, 5.f);
	bounds.setFillColor(sf::Color(30, 30, 30));

	std::list<Cycle*> player;

	// TODO dynamically assign these?
	std::array<v2f, 4> starts
	{
		v2f(105.f, 300.f),
		v2f(695.f, 300.f),
		v2f(400.f, 5.f),
		v2f(400.f, 595.f)
	};

	std::array<float, 4> startds
	{
		0.f,
		180.f,
		90.f,
		270.f
	};

	std::array<sf::Color, 10> colors
	{
		sf::Color(255, 0, 0),
		sf::Color(0, 255, 0),
		sf::Color(0, 0, 255),
		sf::Color(255, 0, 255),
		sf::Color(127, 0, 255),
		sf::Color(255, 255, 0),
		sf::Color(230, 127, 0),
		sf::Color(0, 255, 255),
		sf::Color(0, 100, 0),
		sf::Color(150, 150, 150)
	};

	float timescale = 1.f;

	set_up(window, view, winner, player);
	while (window.isOpen())
	{
		// process input
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();
			else if (event.type == sf::Event::Resized)
				set_up(window, view, winner, player);

			// quit
			if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)
				window.close();

			if (paused)
			{
				// add players
				if (input_is(event, sf::Keyboard::Return, 7))
				{
					int joystick = get_joystick(event);

					// check if the controller is taken
					bool taken = false;

					for (auto p : player)
					{
						if (p->joystick == joystick)
						{
							p->set_ready(true);
							taken = true;
							break;
						}
					}
					// if we can accomodate more players
					if (!taken && player.size() < 4)
					{
						// find color and starting position that aren't being used
						sf::Color c;
						for (auto& col : colors)
						{
							bool taken = false;
							for (auto p : player)
							{
								if (p->color == col)
								{
									taken = true;
									break;
								}
							}
							if (!taken)
							{
								c = col;
								break;
							}
						}
						v2f s;
						int i = 0; // TODO HACKY AS BALLS
						for (auto strt : starts)
						{
							bool taken = false;
							for (auto p : player)
							{
								if (p->start == strt)
								{
									taken = true;
									break;
								}
							}
							if (!taken)
							{
								s = strt;
								break;
							}
							i++;
						}
						player.push_back(new Cycle(s, startds[i], c, font, joystick));
						player.back()->set_text_pos(view.getCenter());
					}
				}
				// remove/unready players
				else if (input_is(event, sf::Keyboard::BackSpace, 6))
				{
					int joystick = get_joystick(event);

					for (auto p : player)
					{
						if (p->joystick == joystick)
						{
							if (p->ready)
								p->set_ready(false);
							else
								player.remove(p);
							break;
						}
					}
				}
				// change colors
				else if (input_is(event, sf::Keyboard::C, 5))
				{
					int joystick = get_joystick(event);

					for (auto p : player)
					{
						if (p->joystick == joystick)
						{
							unsigned int color_index;
							// find current color
							for (color_index = 0; color_index < colors.size(); color_index++)
								if (colors[color_index] == p->color)
									break;

							unsigned int current_color = color_index;
							color_index++;
							// find next available color
							for (; color_index % colors.size() != current_color; color_index++)
							{
								bool taken = false;
								for (auto q : player)
								{
									if (q->color == colors[color_index % colors.size()])
									{
										taken = true;
										break;
									}
								}
								if (!taken)
								{
									p->set_color(colors[color_index % colors.size()]);
									break;
								}
							}
							break;
						}
					}
				}
			}
			else
			{
				for (auto p : player)
					p->bind(event);
			}
		}

		float time = fclock.getElapsedTime().asSeconds();
		fclock.restart();

		// slow motion start
		float stime = clock.getElapsedTime().asSeconds();
		timescale = std::min(3.f, stime) / 3.f;

		if (paused)
		{
			bool all_ready {true};
			for (auto p : player)
			{
				if (!(p->ready))
				{
					all_ready = false;
					break;
				}
			}
			if (all_ready && player.size() > 1)
			{
				paused = false;
				for (auto p : player)
					p->reset();
				clock.restart();
			}
		}
		else
		{
			for (auto p : player)
				p->move(time * timescale);
			// TODO better way?
			for (auto p1 : player)
			{
				for (auto p2 : player)
				{
					if (p1 != p2)
					{
						p1->check_collision(*p2);
						p2->check_collision(*p1);
					}
				}
			}
			for (auto p : player)
				p->in(bounds);

			// TODO visual bug when players collide head-on
			for (auto p : player)
				p->backup();

			win_s.str("");

			bool match_over = true;
			Cycle* survivor = nullptr;

			for(auto p : player)
				if (!(p->crashed))
				{
					if (survivor == nullptr)
						survivor = p;
					else
					{
						match_over = false;
						break;
					}
				}

			if (match_over)
			{
				if (survivor == nullptr)
				{
					win_s << "DRAW";
					winner.setColor(sf::Color(255, 255, 255));
				}
				else
				{
					win_s << "WINNER!";
					winner.setColor(survivor->color);
					survivor->scored();
				}

				paused = true;
				for (auto p : player)
					p->set_ready(false);
			}

			winner.setString(win_s.str());

			sf::FloatRect size = winner.getGlobalBounds();
			winner.setOrigin(size.width / 2, size.height / 2);
		}

		fps_s.str("");
		fps_s << "FPS " << int (1.f / time);
		fps.setString(fps_s.str());

		window.clear(sf::Color(255, 255, 255));

		window.draw(bounds);

		for (auto p : player)
			p->draw(window);
		for (auto p : player)
			p->draw_text(window, paused);

		window.draw(fps);
		window.draw(winner);

		window.display();
	}

	return EXIT_SUCCESS;
}