diff options
| author | manuel <manuel@mausz.at> | 2011-05-05 00:57:07 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-05-05 00:57:07 +0200 |
| commit | ce48af53646cd9e7ec762fc1ac176b3aa620b11d (patch) | |
| tree | f8fbf2cae8c7d0cbac2696a8f4cf94410bfb4928 /pacman-c++/common/bonuspoint.cpp | |
| parent | e54ccad07e256ba877bd41d70bd358bd0085bd1e (diff) | |
| download | foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.gz foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.bz2 foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.zip | |
- refactorized the whole project and made a few subprojects
- replaced tcp with enet
- added connect dialog
- some smaller bugfixes
Diffstat (limited to 'pacman-c++/common/bonuspoint.cpp')
| -rw-r--r-- | pacman-c++/common/bonuspoint.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pacman-c++/common/bonuspoint.cpp b/pacman-c++/common/bonuspoint.cpp new file mode 100644 index 0000000..033b7c8 --- /dev/null +++ b/pacman-c++/common/bonuspoint.cpp | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "bonuspoint.h" | ||
| 2 | #include "constants.h" | ||
| 3 | #include "actor.h" | ||
| 4 | |||
| 5 | #define BONUSPOINTS_NUM_SPRITES 4 | ||
| 6 | |||
| 7 | namespace | ||
| 8 | { | ||
| 9 | QPixmap *pixmap = NULL; | ||
| 10 | } | ||
| 11 | |||
| 12 | BonusPoint::BonusPoint(QGraphicsItem *parent) | ||
| 13 | : GameEntity(parent) | ||
| 14 | { | ||
| 15 | m_type = Type; | ||
| 16 | |||
| 17 | /* empty object for servers */ | ||
| 18 | if (Constants::server) | ||
| 19 | return; | ||
| 20 | |||
| 21 | if (pixmap == NULL) | ||
| 22 | pixmap = new QPixmap(":/bonuspoints"); | ||
| 23 | setPixmap(*pixmap); | ||
| 24 | |||
| 25 | int rand = (int) (BONUSPOINTS_NUM_SPRITES * (qrand() / (RAND_MAX + 1.0))); | ||
| 26 | setSprite(rand * 20 + Constants::sprite_margin, Constants::sprite_margin, Constants::field_size.width, Constants::field_size.height); | ||
| 27 | } | ||
| 28 | |||
| 29 | GameEntity::EnteredState BonusPoint::enter(Actor *actor) | ||
| 30 | { | ||
| 31 | actor->addRoundPoints(Constants::Game::bonus_point_value); | ||
| 32 | return DestroyedEntity; | ||
| 33 | } | ||
| 34 | |||
| 35 | void BonusPoint::onDie(Actor *actor) | ||
| 36 | { | ||
| 37 | actor->eatingFruit(); | ||
| 38 | } | ||
