File indexing completed on 2024-05-05 04:02:04
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 "plane.h" 0009 0010 // Bomber 0011 #include "board.h" 0012 0013 /** The speed the plane will fly at */ 0014 const qreal Plane::DEFAULT_VELOCITY = 0.08; 0015 0016 /** This is the planes size relative to the tile */ 0017 const qreal Plane::PLANE_RELATIVE_SIZE = 1; 0018 0019 /** This is the position before the plane goes off the screen */ 0020 const qreal Plane::PLANE_MAX_POSITION_X = 12; 0021 0022 Plane::Plane(KGameRenderer * renderer, BomberBoard * board) 0023 : Explodable(QStringLiteral("plane"), QStringLiteral("plane_explode"), PLANE_RELATIVE_SIZE, 0024 PLANE_RELATIVE_SIZE, renderer, board) 0025 { 0026 setVelocity(DEFAULT_VELOCITY); 0027 resetPosition(); 0028 } 0029 0030 Plane::~Plane() 0031 { 0032 } 0033 0034 void Plane::resetPosition() 0035 { 0036 m_xPos = 0, m_yPos = 0; 0037 m_nextBoundingRect.moveTo(m_xPos, m_yPos); 0038 } 0039 0040 void Plane::advanceItem() 0041 { 0042 if (state() == State::Moving) { 0043 m_xPos += velocity(); 0044 if (m_xPos > PLANE_MAX_POSITION_X) { 0045 m_xPos = 0; 0046 ++m_yPos; 0047 } 0048 } 0049 m_nextBoundingRect.moveTo(m_xPos + velocity(), m_yPos); 0050 }