/*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/>.
*/

#ifndef DEF_PHYSICS_ENGINE
#define DEF_PHYSICS_ENGINE

#include <SFML/Graphics.hpp>
#include <vector>
#include "Engines/Physics/PhysicsObject.hpp"

//Class managing physics by applying gravity, testing collisions, ...
class PhysicsEngine
{
    public:
        PhysicsEngine();
        PhysicsEngine(const sf::FloatRect &physicsWorld, int ground, int gravity);
        
        void addObject(PhysicsObject *object);
        void removeObject(PhysicsObject *object);
        
        void update();
        void moveObjectX(PhysicsObject *objectToMove, float xPosition);
        void moveObjectY(PhysicsObject *objectToMove, float yPosition);
        
        PhysicsObject *objectHitTest(PhysicsObject *objectToTest);
        bool worldHitTest(PhysicsObject *objectToTest);
        
        bool isOnGround(PhysicsObject *objectToTest);
        
        
        void setPhysicsWorld(const sf::FloatRect &physicsWorld);
        const sf::FloatRect &getPhysicsWorld() const;
        
        void setGroundPosition(int ground);
        int getGoundPosition() const;
        
        void setGravityForce(int gravity);
        int getGravityForce() const;
    
    private:
        std::vector<PhysicsObject*> m_physicsObjectsList;
        
        sf::FloatRect m_physicsWorld;
        int m_ground;
        int m_gravity;
};

#endif