File indexing completed on 2024-05-05 04:02:03

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 John-Paul Stanford <jp@stanwood.org.uk>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 // own
0008 #include "bomb.h"
0009 
0010 // Bomber
0011 #include "board.h"
0012 
0013 /** The speed the bomb will fall at */
0014 const qreal DEFAULT_VELOCITY = 0.2;
0015 
0016 const qreal Bomb::BOMB_RELATIVE_SIZE_H = 0.7;
0017 const qreal Bomb::BOMB_RELATIVE_SIZE_W = 0.2;
0018 
0019 Bomb::Bomb(KGameRenderer * renderer, BomberBoard * board, qreal xPos, qreal yPos, QSize tileSize)
0020     : Explodable(QStringLiteral("bomb"), QStringLiteral("bomb_explode"), BOMB_RELATIVE_SIZE_W,
0021                  BOMB_RELATIVE_SIZE_H, renderer, board)
0022 {
0023     setVelocity(DEFAULT_VELOCITY);
0024     setPosition(xPos, yPos);
0025     resize(tileSize);
0026 }
0027 
0028 Bomb::~Bomb()
0029 {
0030 }
0031 
0032 void Bomb::advanceItem()
0033 {
0034     if (state() == State::Moving) {
0035         m_yPos += velocity();
0036     }
0037     m_nextBoundingRect.moveTo(m_xPos, m_yPos + velocity());
0038 }