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++/block.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++/block.cpp')
| -rw-r--r-- | pacman-c++/block.cpp | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/pacman-c++/block.cpp b/pacman-c++/block.cpp deleted file mode 100644 index 7f9dd14..0000000 --- a/pacman-c++/block.cpp +++ /dev/null | |||
| @@ -1,56 +0,0 @@ | |||
| 1 | #include "block.h" | ||
| 2 | #include "constants.h" | ||
| 3 | #include "actor.h" | ||
| 4 | #include "util.h" | ||
| 5 | #include <QtDebug> | ||
| 6 | |||
| 7 | QMap<Color::Color, QPixmap> Block::m_pixmaps; | ||
| 8 | |||
| 9 | Block::Block(Color::Color color, unsigned int neighbours, QGraphicsItem *parent) | ||
| 10 | : GameEntity(color, parent), m_neighbours(neighbours) | ||
| 11 | { | ||
| 12 | m_type = Type; | ||
| 13 | |||
| 14 | /* empty object for servers */ | ||
| 15 | if (Constants::server) | ||
| 16 | return; | ||
| 17 | |||
| 18 | if (m_pixmaps.find(color) == m_pixmaps.end()) | ||
| 19 | { | ||
| 20 | unsigned int colid = (color == Color::none) ? 0 : Util::floorLog2(color) + 1; | ||
| 21 | QString pixmapName = ":/" + QString("block%1").arg(colid); | ||
| 22 | m_pixmaps[color] = QPixmap(pixmapName); | ||
| 23 | } | ||
| 24 | setPixmap(m_pixmaps.find(color).value()); | ||
| 25 | setNeighbours(m_neighbours); | ||
| 26 | } | ||
| 27 | |||
| 28 | unsigned int Block::neighbours() | ||
| 29 | { | ||
| 30 | return m_neighbours; | ||
| 31 | } | ||
| 32 | |||
| 33 | void Block::setNeighbours(unsigned int neighbours) | ||
| 34 | { | ||
| 35 | m_neighbours = neighbours; | ||
| 36 | setSprite(neighbours * Constants::sprite_offset, 0, Constants::field_size.width, Constants::field_size.height); | ||
| 37 | } | ||
| 38 | |||
| 39 | bool Block::checkEnter(Actor * /* actor */) | ||
| 40 | { | ||
| 41 | if (m_color == Color::none) | ||
| 42 | return false; | ||
| 43 | return true; | ||
| 44 | } | ||
| 45 | |||
| 46 | GameEntity::EnteredState Block::enter(Actor *actor) | ||
| 47 | { | ||
| 48 | if (m_color != Color::none && m_color != actor->color()) | ||
| 49 | return DestroyedActor; | ||
| 50 | return Nothing; | ||
| 51 | } | ||
| 52 | |||
| 53 | void Block::onDie(Actor *actor) | ||
| 54 | { | ||
| 55 | actor->die(); | ||
| 56 | } | ||
