blob: b1ce0e08aa8e119bf49f254c4a7aeb0511a5d81d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "block.h"
#include "constants.h"
#include <QtDebug>
QMap<Color::Color, QPixmap> Block::m_pixmaps;
Block::Block(Color::Color color, unsigned int neighbours, QGraphicsItem *parent)
: PixmapItem(parent)
{
/* empty object for servers */
if (Constants::server)
return;
if (m_pixmaps.find(color) == m_pixmaps.end())
{
unsigned int colid = (color == Color::none) ? 0 : (color >> 1) + 1;
QString pixmapName = ":/" + QString("block%1").arg(colid);
m_pixmaps[color] = QPixmap(pixmapName);
}
setPixmap(m_pixmaps.find(color).value());
setNeighbours(neighbours);
//qDebug() << "loading block w color: " << color;
}
void Block::setNeighbours(unsigned int neighbours)
{
setSprite(neighbours * Constants::sprite_offset, 0, Constants::field_size.width, Constants::field_size.height);
}
|