X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fwinter.h;fp=src%2Fwinter.h;h=9667541b3eeb9a708c97a95489103465b70bd73e;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/winter.h b/src/winter.h new file mode 100644 index 0000000..9667541 --- /dev/null +++ b/src/winter.h @@ -0,0 +1,62 @@ +#ifndef WINTER_H +#define WINTER_H + +#include +#include +#include +#include + +class QGraphicsView; +class QGraphicsScene; + +class SnowFlake : public QGraphicsItem { + public: + enum SnowType { Smilla, Disc, Egg }; + + SnowFlake(QGraphicsScene *scene, SnowType type); + ~SnowFlake(); + QRectF boundingRect() const; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); + void animate(); + void blow(const QPointF &v); + + private: + SnowType type; + int size; + QList lines; + QGraphicsEllipseItem *disc; + QPointF dv; + QPointF dblow; + qreal da; +}; + +class Winter : public QObject { + Q_OBJECT + public: + Winter(QGraphicsView *view); + ~Winter(); + void updateView(); + void setObstacles(QList obslist); + + public slots: + void animate(); + void makeSnow(); + + private: + QGraphicsView *view; + QList fallingSnow; + QList frozenSnow; + int maxFlakes; + QTimer *animTimer; + QTimer *snowTimer; + QList obstacles; + + SnowFlake::SnowType type; + int maxFalling; + int maxUnfreeze; + // QGraphicsRectItem *test; + + QRectF viewRect; +}; + +#endif