From ce48af53646cd9e7ec762fc1ac176b3aa620b11d Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 5 May 2011 00:57:07 +0200 Subject: - refactorized the whole project and made a few subprojects - replaced tcp with enet - added connect dialog - some smaller bugfixes --- pacman-c++/common/bonuspoint.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pacman-c++/common/bonuspoint.cpp (limited to 'pacman-c++/common/bonuspoint.cpp') 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 @@ +#include "bonuspoint.h" +#include "constants.h" +#include "actor.h" + +#define BONUSPOINTS_NUM_SPRITES 4 + +namespace +{ + QPixmap *pixmap = NULL; +} + +BonusPoint::BonusPoint(QGraphicsItem *parent) + : GameEntity(parent) +{ + m_type = Type; + + /* empty object for servers */ + if (Constants::server) + return; + + if (pixmap == NULL) + pixmap = new QPixmap(":/bonuspoints"); + setPixmap(*pixmap); + + int rand = (int) (BONUSPOINTS_NUM_SPRITES * (qrand() / (RAND_MAX + 1.0))); + setSprite(rand * 20 + Constants::sprite_margin, Constants::sprite_margin, Constants::field_size.width, Constants::field_size.height); +} + +GameEntity::EnteredState BonusPoint::enter(Actor *actor) +{ + actor->addRoundPoints(Constants::Game::bonus_point_value); + return DestroyedEntity; +} + +void BonusPoint::onDie(Actor *actor) +{ + actor->eatingFruit(); +} -- cgit v1.2.3