#ifndef DONFEDEJUGADOR_H
#define DONFEDEJUGADOR_H

#include "bottomhitbox.h"
#include "tophitbox.h"
#include "easthitbox.h"
#include "westhitbox.h"
#include "interactable.h"
#include "vidas.h"
#include "points.h"
#include "proyectil.h"

#include <QObject>
#include <QTimer>
#include <QGraphicsPixmapItem>
#include <QPropertyAnimation>
#include <QGraphicsItemGroup>

class donFedeJugador : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT
    Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
    Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
public:
    explicit donFedeJugador(QPixmap pixmap);
    virtual ~donFedeJugador();

    qreal x() const;
    void setX(qreal newX);

    qreal y() const;
    void setY(qreal newY);

    void fallingPlayer();
    void stopFalling();

    void jumpingPlayer();
    void climbPlayer();

    void startLateralMovingRight();
    void startLateralMovingLeft();
    void stopLateralMoving();

    void setLevel(int);
    void interactable1(); //door
    void interactable2(); //palta
    void death();
    points * getPoints();
    vidas * sendLives();
    proyectil *shoot();

public slots:
    void checkInteract();
    void checkEnemy();
    void collidesFloor(bottomHitbox *);
    void collidesRoof(topHitbox *);
    void collidesWallW(westHitbox *);
    void collidesWallE(eastHitbox *);
    void checkYAnimationFinished();
    void checkXAnimationFinished();
    void animationPixmapRefresh();

signals:
    void xChanged(qreal x, qreal y);
    void yChanged(qreal x, qreal y);
    void stoppedJumping();
    void outOfLives();
    void pointsChanged();
    void levelFinished();

private:
    int level;
    QTimer * animationTimer;
    int animationStep;
    points *puntos;
    vidas *lives;
    qreal floorYcoor;
    qreal m_x;
    qreal m_y;
    QPropertyAnimation * xAnimation;
    QPropertyAnimation * yAnimation;
    bool falling;
    bool movingLeft;
    bool movingRight;
    bool lookingRight;
    bool jumping;
    bool climbable;
    bool onFloor;
    bool rightWall;
    bool leftWall;
};

#endif // DONFEDEJUGADOR_H
