/*Copyright (C) 2010-2012 Duncan Deveaux

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 Sprite &sprite) : PhysicsObject(), m_width(width), m_height(height)
{
    setSprite(sprite);
}

void Platform::draw()
{
    m_sprite.draw();
}

//Get and set methods
void Platform::setSprite(const Sprite &sprite)
{
    m_sprite = sprite;
    resizeSprite();
}

const Sprite &Platform::getSprite() const
{
    return m_sprite;
}

//PhysicsObject virtual methods
void Platform::setXPosition(float position)
{
    m_sprite.setXPosition(position);
}

float Platform::getXPosition() const
{
    return m_sprite.getXPosition();
}

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

float Platform::getYPosition() const
{
    return m_sprite.getYPosition();
}

float Platform::getXOrigin() const
{
    return m_sprite.getXOrigin();
}

float Platform::getYOrigin() const
{
    return m_sprite.getYOrigin();
}

float Platform::getWidth() const
{
    return m_width;
}

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

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

void Platform::resizeSprite()
{
    //Resize sprite to platform size
    if (m_sprite.getWidth() > 0 && m_sprite.getHeight() > 0)
    {
        m_sprite.setXScale(m_width / m_sprite.getWidth());
        m_sprite.setYScale(m_height / m_sprite.getHeight());
    }
}
