/*Copyright (C) 2010 Deveaux Duncan

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "Platform.hpp"

Platform::Platform(float width, float height, const sf::Sprite &texture) : m_width(width), m_height(height)
{
    setTexture(texture);
}

void Platform::render(sf::RenderWindow &renderWindow)
{
    renderWindow.Draw(m_texture);
}

//Get and set methods
void Platform::setTexture(const sf::Sprite &texture)
{
    m_texture = texture;
    resizeTexture();
}

const sf::Sprite &Platform::getTexture() const
{
    return m_texture;
}

//PhysicsObject virtual methods
const sf::Vector2f &Platform::getOrigin() const
{
    return m_texture.GetOrigin();
}
        
float Platform::getWidth() const
{
    return m_width;
}

float Platform::getHeight() const
{
    return m_height;
}

void Platform::setXPosition(float position)
{
    m_texture.SetX(position);
}

float Platform::getXPosition() const
{
    return m_texture.GetPosition().x;
}

void Platform::setYPosition(float position)
{
    m_texture.SetY(position);
}

float Platform::getYPosition() const
{
    return m_texture.GetPosition().y;
}

void Platform::takeAHit(float strength)
{
    //Nothing to do...
}

void Platform::resizeTexture()
{
    //Resize texture to platform size
    m_texture.SetScaleX(m_width / m_texture.GetSize().x);
    m_texture.SetScaleY(m_height / m_texture.GetSize().y);
}