diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kolf/ball.h | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kolf/ball.h')
-rw-r--r-- | kolf/ball.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/kolf/ball.h b/kolf/ball.h new file mode 100644 index 00000000..098d82ef --- /dev/null +++ b/kolf/ball.h @@ -0,0 +1,114 @@ +#ifndef KOLF_BALL_H +#define KOLF_BALL_H + +#include <qcanvas.h> +#include <qcolor.h> + +#include <math.h> + +#include "vector.h" +#include "rtti.h" + +enum BallState { Rolling = 0, Stopped, Holed }; + +class Ball : public QCanvasEllipse, public CanvasItem +{ +public: + Ball(QCanvas *canvas); + virtual void aboutToDie(); + + BallState currentState(); + + virtual void resetSize() { setSize(7, 7); } + virtual void advance(int phase); + virtual void doAdvance(); + virtual void moveBy(double dx, double dy); + virtual void setVelocity(double vx, double vy); + + virtual bool deleteable() const { return false; } + + virtual bool canBeMovedByOthers() const { return true; } + + BallState curState() const { return state; } + void setState(BallState newState); + + QColor color() const { return m_color; } + void setColor(QColor color) { m_color = color; setBrush(color); } + + void setMoved(bool yes) { m_moved = yes; } + bool moved() const { return m_moved; } + void setBlowUp(bool yes) { m_blowUp = yes; blowUpCount = 0; } + bool blowUp() const { return m_blowUp; } + + void setFrictionMultiplier(double news) { frictionMultiplier = news; }; + void friction(); + void collisionDetect(double oldx, double oldy); + + virtual int rtti() const { return Rtti_Ball; }; + + int addStroke() const { return m_addStroke; } + bool placeOnGround(Vector &v) { v = oldVector; return m_placeOnGround; } + void setAddStroke(int newStrokes) { m_addStroke = newStrokes; } + void setPlaceOnGround(bool placeOnGround) { m_placeOnGround = placeOnGround; oldVector = m_vector; } + + bool beginningOfHole() const { return m_beginningOfHole; } + void setBeginningOfHole(bool yes) { m_beginningOfHole = yes; } + + bool forceStillGoing() const { return m_forceStillGoing; } + void setForceStillGoing(bool yes) { m_forceStillGoing = yes; } + + Vector curVector() const { return m_vector; } + void setVector(const Vector &newVector); + + bool collisionLock() const { return m_collisionLock; } + void setCollisionLock(bool yes) { m_collisionLock = yes; } + virtual void fastAdvanceDone() { setCollisionLock(false); } + + void setDoDetect(bool yes) { m_doDetect = yes; } + bool doDetect() const { return m_doDetect; } + + virtual void showInfo(); + virtual void hideInfo(); + virtual void setName(const QString &); + virtual void setCanvas(QCanvas *c); + virtual void setVisible(bool yes); + +private: + BallState state; + QColor m_color; + long int collisionId; + double frictionMultiplier; + + bool m_blowUp; + int blowUpCount; + int m_addStroke; + bool m_placeOnGround; + double m_oldvx; + double m_oldvy; + + bool m_moved; + bool m_beginningOfHole; + bool m_forceStillGoing; + + Vector m_vector; + Vector oldVector; + bool m_collisionLock; + + bool m_doDetect; + QCanvasItemList m_list; + + QCanvasText *label; +}; + + +inline int rad2deg(double theDouble) +{ + return (int)((360L / (2L * M_PI)) * theDouble); +} + +inline double deg2rad(double theDouble) +{ + return (((2L * M_PI) / 360L) * theDouble); +} + +#endif |