1 /*
2     SPDX-FileCopyrightText: 2007-2008 John-Paul Stanford <jp@stanwood.org.uk>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 // own
8 #include "bomb.h"
9 
10 // Bomber
11 #include "board.h"
12 
13 /** The speed the bomb will fall at */
14 const qreal DEFAULT_VELOCITY = 0.2;
15 
16 const qreal Bomb::BOMB_RELATIVE_SIZE_H = 0.7;
17 const qreal Bomb::BOMB_RELATIVE_SIZE_W = 0.2;
18 
Bomb(KGameRenderer * renderer,BomberBoard * board,qreal xPos,qreal yPos,QSize tileSize)19 Bomb::Bomb(KGameRenderer * renderer, BomberBoard * board, qreal xPos, qreal yPos, QSize tileSize)
20     : Explodable(QStringLiteral("bomb"), QStringLiteral("bomb_explode"), BOMB_RELATIVE_SIZE_W,
21                  BOMB_RELATIVE_SIZE_H, renderer, board)
22 {
23     setVelocity(DEFAULT_VELOCITY);
24     setPosition(xPos, yPos);
25     resize(tileSize);
26 }
27 
~Bomb()28 Bomb::~Bomb()
29 {
30 }
31 
advanceItem()32 void Bomb::advanceItem()
33 {
34     if (state() == State::Moving) {
35         m_yPos += velocity();
36     }
37     m_nextBoundingRect.moveTo(m_xPos, m_yPos + velocity());
38 }
39