granatier
gamescene.cpp
Go to the documentation of this file.
51 GameScene::GameScene(Game* p_game, KgThemeProvider* p_themeProvider) : m_game(p_game), m_themeProvider(p_themeProvider)
56 connect(p_game, SIGNAL(infoChanged(Granatier::Info::Type)), this, SLOT(updateInfo(Granatier::Info::Type)));
84 connect (playerItem, SIGNAL(bonusItemTaken(BonusItem*)), this, SLOT(removeBonusItem(BonusItem*)));
89 m_remainingTimeLabel->setFont(QFont("Helvetica", Granatier::CellSize * 0.35, QFont::Bold, false));
103 connect(m_themeProvider, SIGNAL(currentThemeChanged(const KgTheme*)), this, SLOT(themeChanged()));
225 m_remainingTimeLabel->setPlainText(QString("%1:%2").arg(nTime/60).arg(nTime%60, 2, 10, QChar('0')));
226 m_remainingTimeLabel->setPos(Granatier::CellSize * m_game->getArena()->getNbColumns() - m_remainingTimeLabel->boundingRect().width(), - m_remainingTimeLabel->boundingRect().height());
238 m_game->getArena()->getNbRows()*Granatier::CellSize + m_remainingTimeLabel->boundingRect().height());
248 newSceneRect.setLeft(oldSceneRect.left() < sidebarRect.left() ? oldSceneRect.left() : sidebarRect.left());
249 newSceneRect.setRight(oldSceneRect.right() > sidebarRect.right() ? oldSceneRect.right() : sidebarRect.right());
250 newSceneRect.setTop(oldSceneRect.top() < sidebarRect.top() ? oldSceneRect.top() : sidebarRect.top());
251 newSceneRect.setBottom(oldSceneRect.bottom() > sidebarRect.bottom() ? oldSceneRect.bottom() : sidebarRect.bottom());
282 ArenaItem* arenaItem = new ArenaItem(j * Granatier::CellSize, i * Granatier::CellSize, m_rendererArenaItems, "");
358 connect(blockItem, SIGNAL(blockItemDestroyed(BlockItem*)), this, SLOT(removeBlockItem(BlockItem*)));
417 connect(bonusItem, SIGNAL(bonusItemDestroyed(BonusItem*)), this, SLOT(removeBonusItem(BonusItem*)));
485 m_arenaBackground->setCacheMode(QGraphicsItem::NoCache); // if cache is set, there are some artifacts; pay attention, that the KGameRenderer cache is used nevertheless
486 m_arenaBackground->setRenderSize(QSize(100, 100)); //just to get something in the background, until the right size is rendered
510 QMap <Player*, KGameRenderer*>::iterator iteratorRendererPlayer = m_mapRendererPlayerItems.begin();
670 int horizontalPixelsPerCell = views().first()->size().width() / (m_minSize.width()/Granatier::CellSize);
671 int verticalPixelsPerCell = views().first()->size().height() / (m_minSize.height()/Granatier::CellSize);
691 QRectF viewRectToScene = QRectF(views().first()->mapToScene(viewRect.topLeft()), views().first()->mapToScene(viewRect.bottomRight()));
692 m_infoOverlay->resizeDimmOverlay(viewRectToScene.x(), viewRectToScene.y(), viewRectToScene.width(), viewRectToScene.height());
817 m_remainingTimeLabel->setPlainText(QString("%1:%2").arg(nTime/60).arg(nTime%60, 2, 10, QChar('0')));
823 m_remainingTimeLabel->setPos(Granatier::CellSize * m_game->getArena()->getNbColumns() - m_remainingTimeLabel->boundingRect().width(), - m_remainingTimeLabel->boundingRect().height());
837 bombItem->updateGraphics(m_SvgScaleFactor); //TODO: use a Renderer class and get the scale factor from a static function during initialization
843 connect(bombItem, SIGNAL(animationFrameChanged(BombItem*,int)), this, SLOT(updateBombExplosionItemAnimation(BombItem*,int)));
895 int anDirectionDetonationCountdown[] = {nDetonationCountdown, nDetonationCountdown, nDetonationCountdown, nDetonationCountdown};
914 //check if there is a bomb or block at the position where the bomb exploded (possible when thrown)
919 bombElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BOMB);
925 dynamic_cast <Bomb*> (element)->initDetonation(bomb->explosionID(), tempBombDetonationCountdown);
930 blockElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BLOCK);
980 if(!abDirectionsDone[direction] && nColumn >= 0 && nColumn < nNumberOfColums && nRow >= 0 && nRow < nNumberOfRows)
982 bombElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BOMB);
983 blockElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BLOCK);
992 dynamic_cast <Bomb*> (element)->initDetonation(bomb->explosionID(), tempBombDetonationCountdown);
1024 bombExplosionItem = new BombExplosionItem (bomb, direction, nBombPower - i, m_rendererBombItems, m_SvgScaleFactor);
void setFont(const QFont &font)
Definition: granatierglobals.h:74
void clear()
Definition: granatierglobals.h:77
QSize size() const
virtual void update(qreal p_x, qreal p_y)
Updates the ElementItem coordinates.
Definition: elementitem.cpp:55
const Key key(const T &value) const
void resizeGraphics(qreal svgScaleFactor)
Signals that the graphics need an update.
Definition: granatierglobals.h:111
Definition: granatierglobals.h:109
qreal x() const
qreal y() const
QList< QGraphicsItem * > items() const
Definition: granatierglobals.h:80
void setRight(qreal x)
Definition: granatierglobals.h:93
virtual QRectF boundingRect() const
QPoint bottomRight() const
void setSceneRect(const QRectF &rect)
QList< Element * > getElements() const
Gets all the Elements that are on the Cell.
Definition: cell.cpp:62
qreal top() const
Definition: granatierglobals.h:95
qreal left() const
void adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
Definition: granatierglobals.h:107
void setLeft(qreal x)
Definition: granatierglobals.h:139
int size() const
void setHeight(qreal height)
Definition: granatierglobals.h:115
qreal bottom() const
GameScene(Game *p_game, KgThemeProvider *p_themeProvider)
Creates a new GameScene instance.
Definition: gamescene.cpp:51
void append(const T &value)
Definition: granatierglobals.h:82
virtual void update(qreal p_x, qreal p_y)
Updates the BombItem coordinates.
Definition: bombitem.cpp:113
QTransform & scale(qreal sx, qreal sy)
void initItemsWithGraphicsFromTheme()
Initializes all items with graphics from the theme.
Definition: gamescene.cpp:271
Definition: granatierglobals.h:129
void removeItem(QGraphicsItem *item)
This class is the graphical representation of a Bomb explosion.
Definition: bombexplosionitem.h:33
void resizeDimmOverlay(qreal x, qreal y, qreal width, qreal height)
Resize dimm overlay.
Definition: infooverlay.cpp:303
void setUndestroyable(int nExplosionID)
Sets the undestroyable explosion IDs.
Definition: bonusitem.cpp:38
void setPos(const QPointF &pos)
QList< QGraphicsView * > views() const
bool isEmpty() const
This class manages the game main loop : it regularly checks the key press events, computes the charac...
Definition: game.h:43
This class describes the common characteristics and behaviour of the bomb item.
Definition: bomb.h:30
iterator begin()
Definition: granatierglobals.h:75
iterator end()
iterator begin()
iterator erase(iterator pos)
Definition: granatierglobals.h:110
const T value(const Key &key) const
This class describes the common characteristics and behaviour of any game Element (character or item)...
Definition: element.h:32
qreal right() const
Definition: granatierglobals.h:94
void stop()
Definition: granatierglobals.h:114
void blockDestroyed(const int row, const int col, Block *block)
remove Block from list and decide to give bonus
Definition: game.cpp:739
Definition: granatierglobals.h:116
Definition: granatierglobals.h:106
void resizeSprites(int delayForBackground=0)
Updates the sprites after a resize.
Definition: gamescene.cpp:662
qreal width() const
void setBottom(qreal y)
void setTop(qreal y)
void setWidth(qreal width)
KGameRenderer * renderer(Granatier::Element::Type type, Player *player=NULL)
Returns the renderer for the requestet Element Type.
Definition: gamescene.cpp:638
virtual void setPosition(qreal p_x, qreal p_y)
Updates the BombExplosionItem coordinates.
Definition: bombexplosionitem.cpp:97
Definition: granatierglobals.h:92
int getColFromX(const qreal p_x) const
Gets the column index corresponding to the given x-coordinate.
Definition: arena.cpp:154
QPoint topLeft() const
Definition: granatierglobals.h:79
This class represents the game sidebar with game information about the player.
Definition: infosidebar.h:53
Definition: granatierglobals.h:128
void start(int msec)
void setPlainText(const QString &text)
qreal height() const
iterator insert(const Key &key, const T &value)
virtual void updateGraphics(qreal svgScaleFactor)
Updates the graphics after a resize.
Definition: elementitem.cpp:65
void setX(qreal x)
void setY(qreal y)
iterator end()
void setDefaultTextColor(const QColor &col)
void cleanUpItemsWithGraphicsFromTheme()
Initializes all items with graphics from the theme.
Definition: gamescene.cpp:538
Definition: granatierglobals.h:108
void addItem(QGraphicsItem *item)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Definition: granatierglobals.h:78
Definition: granatierglobals.h:81
Definition: granatierglobals.h:73
void setZValue(qreal z)
void setupThemeRenderer()
setup the KGameRenderer for the selected theme and if necessary the default theme ...
Definition: gamescene.cpp:112
Cell getCell(const int p_row, const int p_column) const
Gets the Cell at the given coordinates.
Definition: arena.cpp:120
Definition: granatierglobals.h:112
int getRowFromY(const qreal p_y) const
Gets the row index corresponding to the given y-coordinate.
Definition: arena.cpp:144
const T value(const Key &key) const
void setSingleShot(bool singleShot)
Definition: granatierglobals.h:96
Definition: granatierglobals.h:76
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.