From bfaf2e63e64169abbb1a4c079a937091060574b7 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 5 Apr 2011 12:26:04 +0200 Subject: forgot some commits.. replace std::map with QMap --- pacman-c++/bonuspoint.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pacman-c++/bonuspoint.cpp') diff --git a/pacman-c++/bonuspoint.cpp b/pacman-c++/bonuspoint.cpp index e2fdba0..8ebc195 100644 --- a/pacman-c++/bonuspoint.cpp +++ b/pacman-c++/bonuspoint.cpp @@ -1,14 +1,21 @@ #include "bonuspoint.h" +#include "constants.h" +#include + +#define BONUSPOINTS_NUM_SPRITES 4 namespace { - QPixmap *pixmap = 0; + QPixmap *pixmap = NULL; } BonusPoint::BonusPoint(QGraphicsItem *parent) : PixmapItem(parent) { - if (pixmap == 0) - pixmap = new QPixmap(":/cherry"); + if (pixmap == NULL) + pixmap = new QPixmap(":/bonuspoints"); setPixmap(*pixmap); + + int rand = (int) (BONUSPOINTS_NUM_SPRITES * (qrand() / (RAND_MAX + 1.0))); + setSprite(rand * 20 + SPRITE_MARGIN, SPRITE_MARGIN, SPRITE_WIDTH, SPRITE_HEIGHT); } -- cgit v1.2.3