#include "Case.h"

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

#include <string>
#include <iostream>

#define TILE_WIDTH 30
#define TILE_HEIGHT 30

using namespace sf;

Case::Case()
{
    //ctor
}

Case::Case(sf::RenderWindow* window, float x, float y)
{
    m_positionX=x;
    m_positionY=y;
    m_value=0;
    m_statut=false;
    m_window=window;

}

void Case::Settexture(std::string name)
{
    if(!m_texture.loadFromFile(name.c_str())){std::cout<<"|!|Texture loading failed :" << name << std::endl;}
    m_sprite.setTexture(m_texture);
    m_sprite.setTextureRect(IntRect(m_value*(TILE_WIDTH+1),0,TILE_WIDTH, TILE_HEIGHT));
    std::cout<< "0) Texture loaded "<<std::endl;
}

void Case::draw(int whichOneX,int whichOneY,int x, int y)
{
    {m_sprite.setTextureRect(IntRect(whichOneX*(TILE_WIDTH+1),whichOneY*(TILE_HEIGHT+2),TILE_WIDTH, TILE_HEIGHT));}

    m_sprite.setPosition(x*TILE_WIDTH,y*TILE_HEIGHT);
    m_window->draw(m_sprite);

}

Case::~Case()
{
    //dtor
}
