summaryrefslogtreecommitdiffstats
path: root/pacman-c++/bonuspoint.cpp
blob: 0517c64c90a4c5262f0689d1dbbe338841185dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "bonuspoint.h"
#include "constants.h"
#include <QDebug>

#define BONUSPOINTS_NUM_SPRITES 4

namespace
{
  QPixmap *pixmap = NULL;
}

BonusPoint::BonusPoint(QGraphicsItem *parent)
  : PixmapItem(parent)
{
  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);
}