Beispiel #1
0
	vector<vector<Tile*>> LoadLevel(const char* filename)
	{
		sf::Color pixCol;
		vector<vector<Tile*>> tils;

		sf::Image image;
		if (!image.loadFromFile(filename)) return tils;

		if (!backGroundTex.loadFromFile("DarkBrick.png")) return tils;
		if (!foreGroundTex.loadFromFile("Brick.png")) return tils;

		tils.resize(image.getSize().x);
		for (int i = 0; i < image.getSize().x; i++)
		{
			tils[i].resize(image.getSize().y);
			for (int j = 0; j < image.getSize().y; j++)
			{
				pixCol = image.getPixel(i, j);

				if (pixCol == sf::Color::White)
					tils[i][j] = new Tile(sf::Vector2f(i * 64, j * 64), backGroundTex, false);
				else if (pixCol == sf::Color::Black)
					tils[i][j] = new Tile(sf::Vector2f(i * 64, j * 64), foreGroundTex, true);
			}
		}

		return tils;
	}
Beispiel #2
0
void StateGameMenu::Initialize()
{
	menu_pointer_tex.loadFromFile("./Resources/Images/gamemenu_pointer.png");
	menu_pointer_sprt.setTexture(menu_pointer_tex);

	menu_tex.loadFromFile("./Resources/Images/gamemenu.png");
	menu_sprt.setTexture(menu_tex);
	menu_sprt.setPosition(180, 142);
}
			bool actualizarImagenExplocionPequenia(float currentTime){
			float temporal= currentTime - tiempoInicio;
			if(temporal <100){
			imagen.loadFromFile("graphics/SmallExp00.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >100 && temporal < 200){
			imagen.loadFromFile("graphics/SmallExp00.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >200 && temporal < 300){
			imagen.loadFromFile("graphics/SmallExp01.png");
			sprite.setTexture(imagen, true);
			return true;
			}	
			if(temporal >300 && temporal < 400){
			imagen.loadFromFile("graphics/SmallExp01.png");
			sprite.setTexture(imagen, true);
			}
			if(temporal >400 && temporal < 500){
			imagen.loadFromFile("graphics/SmallExp02.png");
			sprite.setTexture(imagen, true);
			}
			if(temporal >500 && temporal < 600){
			imagen.loadFromFile("graphics/SmallExp02.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >600 && temporal < 700){
			imagen.loadFromFile("graphics/SmallExp03.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >700 && temporal < 800){
			imagen.loadFromFile("graphics/SmallExp03.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >800 && temporal < 1200){
			imagen.loadFromFile("graphics/SmallExp04.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			if(temporal >1200 && temporal < 1700){
			imagen.loadFromFile("graphics/SmallExp04.png");
			sprite.setTexture(imagen, true);
			return true;
			}
			else
			{
				return false;
			}
			
		};
Beispiel #4
0
int Presentation::load() {



    if (!textureFolder.loadFromFile("folder.png")) {
        std::cerr << "Error loading folder.png" << std::endl;
        return (-1);
    }

    if (!textureClose.loadFromFile("close.png")) {
        std::cerr << "Error loading close.png" << std::endl;
        return (-1);
    }
    return 0;
}
Beispiel #5
0
void Level::loadFromLv(b2World& World, std::string levelPath)
{
  std::cout << levelPath << std::endl;
  std::string line;
  std::ifstream myfile (levelPath);
  if (myfile.is_open())
  {
    //current level object init
    while ( getline (myfile,line) )
    {
      std::regex groundRegex("(ground),(.*),(.*),(.*),(.*),(.*)");
      std::smatch groundObject;

      if (std::regex_match(line,groundObject,groundRegex))
      {
        std::cout <<  groundObject[5].str() << std::endl;

        CreateGround(World, std::stof(groundObject[2].str()), stof(groundObject[3].str()), stof(groundObject[4].str()), stof(groundObject[5].str()));
        // CreateGround(World, 5, 5, 5, stof(groundObject[5].str()));
        GroundTexture.loadFromFile(groundObject[6]);

        GroundTexture.setRepeated(true);

      }


    }
    std::cout << levelPath << std::endl;

    myfile.close();
  }
  else std::cout << "Unable to open file" << std::endl;
}
Beispiel #6
0
	void _Log::load_image(){
		if( image_loaded == false && image_path.length() != 0 ) {
			texture_1.loadFromFile( image_path );

			Sprite.setTexture( texture_1, false );
			sf::IntRect spr_data = Sprite.getTextureRect();
			float x,y = WINDOW_HEIGHT - spr_data.height;

			switch( align ){

			case 1: x = 0.f; break;
			case 2: x = WINDOW_WIDTH * 0.25 - spr_data.width /2; break;
			case 3: x = WINDOW_WIDTH * 0.5  - spr_data.width /2; break;
			case 4: x = WINDOW_WIDTH * 0.75  - spr_data.width /2; break;
			case 5: x = WINDOW_WIDTH - spr_data.width; break;

			}

			Sprite.setPosition( x, y );

			cout << x << " " << y << endl;

			image_loaded = true;
		}
	}
Beispiel #7
0
int main() {
  int WindowX, WindowY;

  std::string str("Cards/cardback1.png");

  std::cout << str << std::endl;

  if (!back.loadFromFile(str)) { // TODO error
    std::cout << "Couldn't load cardback img" << std::endl;
  }
  WindowX = 700;
  WindowY = 500;
  //Card c(Card::Seven, Card::Spade, true);
  //c.rotate(90.0f);
  Deck deck(true);
  Hand h(true, false, sf::FloatRect(100.0f, 100.0f, static_cast<float>(WindowX / 5), static_cast<float>(WindowY)), Hand::down, deck.getKozer());
  //h.takeCard(c);
  
  // Create the main window
  sf::VideoMode v = sf::VideoMode::getDesktopMode();

  sf::RenderWindow window(sf::VideoMode(v.width, v.height), "SFML window");
  WindowX = v.width;
  WindowY = v.height;
  //c.scale(WindowX, WindowY);
  //c.rotate(90.0f);
  //c.setPos(50.0f, 50.0f);
  deck.scale(WindowX, WindowY);
  deck.setPos(WindowX / 1.5, WindowY / 1.5);
  while (window.isOpen()) {
    // Process events
    sf::Event event;
    while (window.pollEvent(event)) {
      // Close window : exit
      if (event.type == sf::Event::Closed)
        window.close();
      if(event.type == sf::Event::KeyPressed){
	 
	  switch(event.key.code){
	  case sf::Keyboard::Space:
	      if(!deck.empty()){
		  Card temp = deck.takeTop();
		  h.takeCard(temp);
	      }
	      break;
	      
	  default:
	      break;
	  }
      }
    }
    // Clear screen
    window.clear(sf::Color(85, 120, 47, 160));
    window.draw(h);
    window.draw(deck);
    window.display();
  }
  return EXIT_SUCCESS;
}
Beispiel #8
0
void StateCharacterSelect::Initialize()
{
	background_tex.loadFromFile("./Resources/Images/character_select_bg.png");
	background.setTexture(background_tex);

	background_activated_tex.loadFromFile("./Resources/Images/character_select_bg_selected.png");
	for(int i=0; i<4; i++)
		activated[i].setTexture(background_activated_tex);
	
	activated[0].setTextureRect(sf::IntRect(0, 0, 160, 480));
	activated[0].setPosition(0, 0);
	activated[1].setTextureRect(sf::IntRect(160, 0, 160, 480));
	activated[1].setPosition(160, 0);
	activated[2].setTextureRect(sf::IntRect(320, 0, 160, 480));
	activated[2].setPosition(320, 0);
	activated[3].setTextureRect(sf::IntRect(480, 0, 160, 480));
	activated[3].setPosition(480, 0);
}
Beispiel #9
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 #10
0
void TexturesManager::loadTexture(
    sf::Texture& texture,
    const std::string& path
) &
{
    if (!texture.loadFromFile("res/images/" + path + ".png"))
    {
        throw std::invalid_argument("Cannot load texture : " + path);
    }
}
Beispiel #11
0
	Goomba(float i, float j) {
		_rect.setSize(sf::Vector2f(32, 32));
		_rect.setFillColor(sf::Color::Blue);
		if (_textureG.loadFromFile("goomba.png")) {
			_textureG.setSmooth(true);
			_spriteG.setTexture(_textureG);
			_spriteG.setScale(1.9, 1.9);
		}
		_spriteG.setPosition(50, 350);
	}
ComponentFactory::ComponentFactory()
{
  t.loadFromFile( "../assets/art/unit1.png" );

  m_functionMap[ EComponentTypes::CT_RenderComponent ] = &MakeRenderComponent;
  m_functionMap[ EComponentTypes::CT_PathfindingAgentComponent ] = &MakePathfindingAgentComponent;
  m_functionMap[ EComponentTypes::CT_WanderingComponent ] = &MakeWanderingComponent;


}
Beispiel #13
0
void Unit::load(std::string filename) {
	if(!_texture.loadFromFile(filename)) {
		_filename = "";
		_isLoaded = false;
	} 
	else {
		_filename = filename;
		_sprite.setTexture(_texture);
		_isLoaded = true;
	}
}
Beispiel #14
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 #15
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_texture()
	{
		
		assert(m_file_name != "");
		
		if (!m_texture.loadFromFile(m_file_name))
		{
				
			std::cout << m_file_name << " not found!\n";
				
		}
		 
	}
 bool TextureResourceHandler::loadResourceFromFile(sf::Texture& resource, std::string filename)
 {
   bool result = false;
   //Check file exists
   if(boost::filesystem::exists(filename))
     {
       result = resource.loadFromFile(filename);
     }
   else
     {
       LOGE("TextureResourceHandler::loadResourceFromFile() - File not found: "<<filename);
     }
   return result;
 }
Arvid::Arvid(sf::Vector2f &position) /*:
	mIdleLeftAnimation	("", 0, 0),
	mIdleRightAnimation ("", 0, 0),
	mRunLeftAnimation	("", 0, 0),
	mRunRightAnimation	("", 0, 0),
	mJumpAnimation		("", 0, 0)*/
{ 
	mEntityKind = ARVID;
	setPosition(position);
	TEXTURE.loadFromFile("GUBBJEVEL.png");
	SPRITE.setTexture(TEXTURE);
	mHitBox.width = SPRITE.getLocalBounds().width;
	mHitBox.height = SPRITE.getLocalBounds().height;
	SPRITE.setPosition(position);
}
	void setup()
	{
		window = new sf::RenderWindow(sf::VideoMode(800, 600), "Untitled");
		window->setFramerateLimit(60);

		clock = new sf::Clock();

		// textures are apparently stored in the graphic card's memory rather than RAM
		tile_texture = new sf::Texture();
		tile_texture->loadFromFile("assets/gfx/tiles/basic1.png");

		// sprites are used to position and draw textures
		tile_sprite = new sf::Sprite();
		tile_sprite->setTexture(*tile_texture);
		tile_sprite->setColor(sf::Color(255, 255, 255, 255));
	}
Beispiel #20
0
bool load(const std::string& tileset, sf::Vector2u tileSize, const int* tiles, unsigned int width, unsigned int height)
{
	// load the tileset texture
	if (!m_tileset.loadFromFile(tileset))
		return false;

	// resize the vertex array to fit the level size
	m_vertices.setPrimitiveType(sf::Quads);
	m_vertices.resize(width * height * 4);

	// populate the vertex array, with one quad per tile
	for (unsigned int i = 0; i < width; ++i)
		for (unsigned int j = 0; j < height; ++j)
		{
			/*
			// get the current tile number
			int tileNumber = tiles[i + j * width];

			// find its position in the tileset texture
			int tu = tileNumber % (m_tileset.getSize().x / tileSize.x);
			int tv = tileNumber / (m_tileset.getSize().x / tileSize.x);
			*/
			// get a pointer to the current tile's quad
			sf::Vertex* quad = &m_vertices[(i + j * width) * 4];

			// define its 4 corners
			quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y);
			quad[1].position = sf::Vector2f((i + 1) * tileSize.x, j * tileSize.y);
			quad[2].position = sf::Vector2f((i + 1) * tileSize.x, (j + 1) * tileSize.y);
			quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y);

			quad[0].texCoords = sf::Vector2f(0, 0);
			quad[1].texCoords = sf::Vector2f(0, 32);
			quad[2].texCoords = sf::Vector2f(32, 0);
			quad[3].texCoords = sf::Vector2f(32, 32);
			/*
			// define its 4 texture coordinates
			quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
			quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
			quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
			quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
			*/
		}

		return true;
}
Beispiel #21
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 ) );
        }
Beispiel #22
0
GameGrid::GameGrid(int w, int h)
{
	drive_tex.loadFromFile("drive.png");
	drive.setTexture(drive_tex);

	border_size = 1.0f;
	bgColor = { 0,0,0 };
	borderColor = { 100, 0 , 0 };


	numCells = { w, h };
	selected = sf::Vector2i{ -1, -1 };

	cellData.resize(w*h);
	for (auto& c : cellData) { c = GameCell(); }

	RebuildVerts();
}
Beispiel #23
0
 StaticBGImpl(const std::string & src_file, 
     unsigned int wwidth, unsigned int wheight, unsigned int iwidth, unsigned int iheight)
 : m_texture(new sf::Texture), m_sprite(0),
   m_wwidth(wwidth), m_wheight(wheight), m_iwidth(iwidth), m_iheight(iheight)
 {
     if(!m_texture->loadFromFile(src_file))
     {
         std::cerr << "StaticBG, could not load texture from: " << src_file << std::endl;
     }
     m_sprite = new sf::Sprite(*m_texture);
     if(iwidth == 0 || iheight == 0)
     {
         m_iwidth  = m_wwidth;
         m_iheight = m_wheight;
     }
     m_sprite->setScale((float)m_iwidth/(float)m_wwidth, (float)m_iheight/(float)m_wheight);
     m_sprite->setPosition((float)(m_wwidth/2 - m_iwidth/2), (float)(m_wheight/2 - m_iheight/2));
 }
Beispiel #24
0
void initialize()
{
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat mat_shininess[] = { 10.0 };
    GLfloat white_light[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat grey_light[] = { 0.6, 0.6, 0.6, 1.0 };

    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_SMOOTH);

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

    glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
    glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);

    GLfloat blue_light[] = { 0.0, 0.0, 1.0, 1.0 };

    glLightfv(GL_LIGHT1, GL_DIFFUSE, blue_light);
    glLightfv(GL_LIGHT1, GL_SPECULAR, blue_light);

    glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 60.0);
    glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 3.3);

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, grey_light);
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_DEPTH_TEST);

    glEnable(GL_CULL_FACE);
    glEnable(GL_TEXTURE_2D);

    if (!texture.loadFromFile("earth.jpg"))
    {
        printf("Could not load texture");
    }

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
Background(sf::RenderWindow &window) {
    background.loadFromFile("res/fondo1_baja.jpg");
    sprite.setTexture(background);
    width = 1;
    height = 1;
    actualAnimation = 0;
    timeBetweenAnimations = 1;
    timeSinceLastAnimation = 0.0;

    animationWidth = sprite.getGlobalBounds().width/width;
    animationHeight = sprite.getGlobalBounds().height/height;

    if(window.getSize().y/animationHeight < window.getSize().x/animationWidth)
        sprite.scale(2*window.getSize().y/animationHeight,2*window.getSize().y/animationHeight);
    else
        sprite.scale(2*window.getSize().x/animationWidth,2*window.getSize().x/animationWidth);

    //sprite.setOrigin(sf::Vector2f(animationWidth/2, animationHeight/2));
    sprite.setPosition(window.getSize().x/2, window.getSize().y/2.0);

}
Beispiel #26
0
	bool TextureHandler::loadFromFile(const typeAssetID assetID, sf::Texture& asset)
	{
		// Start with a return result of false
		bool succLoad = false;

		// Retrieve the filename for this asset
		std::string filename = assetID;

		// Was a valid filename found? then attempt to load the asset from anFilename
		if(filename.length() > 0)
		{
			// Load the asset from a file
			succLoad = asset.loadFromFile(filename);
		}
		else
		{
			ELOG() << "TextureHandler::LoadFromFile(" << assetID
				<< ") No filename provided!" << std::endl;
		}

		// Return anResult of true if successful, false otherwise
		return succLoad;
	}
Beispiel #27
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 display(sf::RenderWindow* window, std::string pathImage){
        open = true;
            t.loadFromFile(pathImage);
            s = sf::Sprite();
            s.setTexture(t);
            s.scale(window->getSize().y/s.getGlobalBounds().height,window->getSize().y/s.getGlobalBounds().height);
            s.setPosition(window->getSize().x/2 - s.getGlobalBounds().width/2, 0);
        while(open){
            
            sf::Event event;
            while (window->pollEvent(event)) {
                switch (event.type) {
                case sf::Event::Closed:
                    window->close();
                    break;
                case sf::Event::KeyPressed:
                    if (event.key.code == sf::Keyboard::Escape) window->close();
                    break;
                case sf::Event::MouseButtonPressed:
                    if (event.mouseButton.button == sf::Mouse::Left) {
                        open = false;
                    }
                    break;
                default:
                    break;
                }
                if( event.type == sf::Event::KeyPressed ||
                event.type == sf::Event::MouseButtonPressed||
                event.type == sf::Event::TouchEnded           )  open = false;
            }

            window->clear();
            window->draw(s);

            window->display();
                
        }
        
        sf::Clock timer;
        sf::Sprite dark;
        sf::Texture text;
        bool closing = true;
        text.loadFromFile("res/pics/black.png");
        
        dark.setTexture(text);
        dark.setOrigin(dark.getLocalBounds().width/2,dark.getLocalBounds().height/2);
        dark.setPosition(window->getSize().x/2,window->getSize().y/2);
        float scale = 1/dark.getGlobalBounds().width;;
        
        float time = 0;
        while(closing and wantAnimation){            
            dark.setScale(scale,scale);
            time += timer.restart().asSeconds();
            if(time > 0.1){
                scale *= 1.5;
                time = 0;
            }
            window->clear();
            window->draw(s);
            window->draw(dark);
            window->display();
            if(dark.getGlobalBounds().width > window->getSize().x) closing = false;
        }
        //clean events 
        sf::Event e; while (window->pollEvent(e)) { }
    }
std::map<std::string, sf::IntRect> makePlayerAnimation(Video::Render::Animation &animation) {
    static sf::Texture texture;
    if(!texture.loadFromFile("assets/dummy_player_spritesheet.png")) {
        throw std::runtime_error("Error loading player animation texture");
    }

    Video::Render::AnimatedSprite idleSequence(texture);
    Video::Render::AnimatedSprite fallSequence(texture);
    Video::Render::AnimatedSprite slashSequence(texture);
    Video::Render::AnimatedSprite castSequence(texture);
    Video::Render::AnimatedSprite runSequence(texture);
    Video::Render::AnimatedSprite airSlashSequence(texture);
    Video::Render::AnimatedSprite hurtSequence(texture);
    Video::Render::AnimatedSprite jumpSequence(texture);
    
    Video::Render::Sprite::Frame frameBuffer[21];

    std::map<std::string, sf::IntRect> seq_solids;
    
    //everything was offset by 1px (5->6, 0->1, 55->54, 70->69...). why?
    //idle
    frameBuffer[0].setTextureSegment(sf::IntRect(5, 6, 55, 70));
    frameBuffer[1].setTextureSegment(sf::IntRect(85, 6, 55, 70));
    frameBuffer[2].setTextureSegment(sf::IntRect(165, 6, 55, 70));
    frameBuffer[3].setTextureSegment(sf::IntRect(245, 6, 55, 70));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("idle", sf::IntRect(10, 2, 30, 68)));
    
    //fall
    frameBuffer[4].setTextureSegment(sf::IntRect(343, 6, 48, 69));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("fall", sf::IntRect(13, 2, 30, 64)));
    
    //slash
    frameBuffer[5].setTextureSegment(sf::IntRect(3, 100, 79, 68));
    frameBuffer[6].setTextureSegment(sf::IntRect(82, 100, 79, 68));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("slash", sf::IntRect(12, 2, 30, 66)));
    
    //cast
    frameBuffer[7].setTextureSegment(sf::IntRect(188, 101, 78, 68));
    frameBuffer[8].setTextureSegment(sf::IntRect(268, 101, 78, 68));
    frameBuffer[9].setTextureSegment(sf::IntRect(348, 101, 78, 68));
    frameBuffer[10].setTextureSegment(sf::IntRect(428, 101, 78, 68));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("cast", sf::IntRect(10, 1, 30, 67)));
    
    //run
    frameBuffer[11].setTextureSegment(sf::IntRect(0, 202, 69, 55));
    frameBuffer[12].setTextureSegment(sf::IntRect(74, 202, 69, 55));
    frameBuffer[13].setTextureSegment(sf::IntRect(154, 202, 69, 55));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("run", sf::IntRect(19, 2, 40, 53)));
    
    //air slash
    frameBuffer[14].setTextureSegment(sf::IntRect(257, 193, 79, 63));
    frameBuffer[15].setTextureSegment(sf::IntRect(336, 193, 79, 63));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("air", sf::IntRect(19, 2, 30, 61)));
    
    //hurt
    frameBuffer[16].setTextureSegment(sf::IntRect(4, 288, 50, 67));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("hurt", sf::IntRect(8, 4, 40, 60)));
    
    //having one solid here is problematic, because first two frames are crouching, so shorter...
    //jump
    frameBuffer[17].setTextureSegment(sf::IntRect(96, 280, 67, 70));
    frameBuffer[18].setTextureSegment(sf::IntRect(174, 280, 67, 70));
    frameBuffer[19].setTextureSegment(sf::IntRect(250, 280, 67, 70));
    frameBuffer[20].setTextureSegment(sf::IntRect(341, 280, 67, 70));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("jump", sf::IntRect(19, 1, 30, 68)));
    
    for(int i = 0; i < 21; ++i) {
        frameBuffer[i].setDuration(sf::seconds(1.0f/15.0f));
    }
    
    // last one should be actually four but for now lets skip this frame
    int famt[] = {4, 1, 2, 4, 3, 2, 1, 3};
    Video::Render::AnimatedSprite *seq[] = {&idleSequence, &fallSequence, &slashSequence,
        &castSequence, &runSequence, &airSlashSequence, &hurtSequence, &jumpSequence};
        
    for(int i = 0, j = 0; i < 8; ++i) {
        for(int k = 0; k < famt[i]; ++k) {
            seq[i]->insertFrame(frameBuffer[j]);
            j += 1;
        }
    }
    
    animation.addSequence("idle", idleSequence, true);
    animation.addSequence("fall", fallSequence, true);
    animation.addSequence("slash", slashSequence, true);
    animation.addSequence("cast", castSequence, true);
    animation.addSequence("run", runSequence, true);
    animation.addSequence("air", airSlashSequence, true);
    animation.addSequence("hurt", hurtSequence, true);
    animation.addSequence("jump", jumpSequence, true);
    
    return seq_solids;
}
std::map<std::string, sf::IntRect> makeGuardAnimation(Video::Render::Animation &animation) {
    static sf::Texture texture;
    if(!texture.loadFromFile("assets/dummy_guard_spritesheet.png")) {
        throw std::runtime_error("Error loading guard animation texture");
    }

    Video::Render::AnimatedSprite idleSequence(texture);
    Video::Render::AnimatedSprite fallSequence(texture);
    Video::Render::AnimatedSprite slashSequence(texture);
    Video::Render::AnimatedSprite runSequence(texture);
    Video::Render::AnimatedSprite hurtSequence(texture);
    Video::Render::AnimatedSprite jumpSequence(texture);
    
    Video::Render::Sprite::Frame frameBuffer[15];

    std::map<std::string, sf::IntRect> seq_solids;
    
    //idle
    frameBuffer[0].setTextureSegment(sf::IntRect(9, 8, 67, 92));
    frameBuffer[1].setTextureSegment(sf::IntRect(89, 8, 67, 92));
    frameBuffer[2].setTextureSegment(sf::IntRect(169, 8, 67, 92));
    frameBuffer[3].setTextureSegment(sf::IntRect(249, 8, 67, 92));
    frameBuffer[4].setTextureSegment(sf::IntRect(329, 8, 67, 92));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("idle", sf::IntRect(12, 10, 40, 82)));
    
    //fall
    frameBuffer[5].setTextureSegment(sf::IntRect(17, 133, 64, 90));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("fall", sf::IntRect(2, 10, 40, 78)));
    
    //slash
    frameBuffer[6].setTextureSegment(sf::IntRect(123, 135, 100, 92));
    frameBuffer[7].setTextureSegment(sf::IntRect(220, 135, 100, 92));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("slash", sf::IntRect(25, 12, 40, 79)));
    
    //run
    frameBuffer[8].setTextureSegment(sf::IntRect(132, 271, 75, 92));
    frameBuffer[9].setTextureSegment(sf::IntRect(216, 271, 75, 92));
    frameBuffer[10].setTextureSegment(sf::IntRect(292, 271, 75, 92));
    frameBuffer[11].setTextureSegment(sf::IntRect(372, 271, 75, 92));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("run", sf::IntRect(20, 10, 40, 82)));
    
    //hurt
    frameBuffer[12].setTextureSegment(sf::IntRect(8, 281, 68, 89));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("hurt", sf::IntRect(16, 7, 40, 82)));
    
    //jump
    frameBuffer[13].setTextureSegment(sf::IntRect(22, 395, 56, 96));
    frameBuffer[14].setTextureSegment(sf::IntRect(107, 395, 56, 96));
    seq_solids.insert(std::pair<std::string, sf::IntRect>("jump", sf::IntRect(14, 8, 40, 85)));
    
    for(int i = 0; i < 15; ++i) {
        frameBuffer[i].setDuration(sf::seconds(1.0f/15.0f));
    }
    
    int famt[] = {5, 1, 2, 4, 1, 2};
    Video::Render::AnimatedSprite *seq[] = {&idleSequence, &fallSequence, &slashSequence,
        &runSequence, &hurtSequence, &jumpSequence};
        
    for(int i = 0, j = 0; i < 6; ++i) {
        for(int k = 0; k < famt[i]; ++k) {
            seq[i]->insertFrame(frameBuffer[j]);
            j += 1;
        }
    }
    
    animation.addSequence("idle", idleSequence, true);
    animation.addSequence("fall", fallSequence, true);
    animation.addSequence("slash", slashSequence, true);
    animation.addSequence("run", runSequence, true);
    animation.addSequence("hurt", hurtSequence, true);
    animation.addSequence("jump", jumpSequence, true);
    
    return seq_solids;
}