• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

granatier

  • sources
  • kde-4.14
  • kdegames
  • granatier
  • src
bomb.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Mathias Kraus <k.hias@gmx.de>
3  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
4  * Copyright 2007-2008 Pierre-BenoĆ®t Besse <besse.pb@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "bomb.h"
21 #include "arena.h"
22 
23 #include <QTimer>
24 
25 #include <cstdlib>
26 
27 const int nMortarRampEnd = Granatier::FPS * 50 / 1000.0;
28 const int nMortarPeak = (Granatier::FPS * 800 / 1000.0) / 2 + nMortarRampEnd;
29 const int nMortarGround = (Granatier::FPS * 800 / 1000.0) + nMortarRampEnd;
30 
31 Bomb::Bomb(qreal fX, qreal fY, Arena* p_arena, int nBombID, int nDetonationCountdown) : Element(fX, fY, p_arena), m_xSpeed(0), m_ySpeed(0)
32 {
33  m_type = Granatier::Element::BOMB;
34 
35  m_xInit = fX;
36  m_yInit = fY;
37  m_x = fX;
38  m_y = fY;
39 
40  m_bombPower = 1;
41 
42  int currentRow = m_arena->getRowFromY(m_y);
43  int currentCol = m_arena->getColFromX(m_x);
44  m_arena->setCellElement(currentRow, currentCol, this);
45 
46  m_detonated = false;
47 
48  m_bombID = nBombID;
49  m_explosionID = nBombID;
50 
51  // Define the timer which sets the puls frequency
52  m_detonationCountdownTimer = new QTimer(this);
53  m_detonationCountdownTimer->setInterval(nDetonationCountdown);
54  m_detonationCountdownTimer->setSingleShot(true);
55  m_detonationCountdownTimer->start();
56  connect(m_detonationCountdownTimer, SIGNAL(timeout()), this, SLOT(detonate()));
57 
58  m_mortarTimer = 0;
59  m_mortarState = -1;
60  m_thrown = false;
61  m_stopOnCenter = false;
62  m_falling = false;
63 
64  moveOnCenter();
65 }
66 
67 Bomb::~Bomb()
68 {
69  delete m_detonationCountdownTimer;
70  delete m_mortarTimer;
71 }
72 
73 void Bomb::goUp()
74 {
75 }
76 
77 void Bomb::goDown()
78 {
79 }
80 
81 void Bomb::goRight()
82 {
83 }
84 
85 void Bomb::goLeft()
86 {
87 }
88 
89 void Bomb::updateMove()
90 {
91  if(m_detonated)
92  {
93  return;
94  }
95 
96  int currentRow = m_arena->getRowFromY(m_y);
97  int currentCol = m_arena->getColFromX(m_x);
98  //check if the bomb is on an arrow, mortar or hole
99  if(m_mortarState < 0 && m_xSpeed == 0 && m_ySpeed == 0)
100  {
101  switch (m_arena->getCell(currentRow, currentCol).getType())
102  {
103  case Granatier::Cell::ARROWUP:
104  setYSpeed(-5);
105  break;
106  case Granatier::Cell::ARROWRIGHT:
107  setXSpeed(5);
108  break;
109  case Granatier::Cell::ARROWDOWN:
110  setYSpeed(5);
111  break;
112  case Granatier::Cell::ARROWLEFT:
113  setXSpeed(-5);
114  break;
115  case Granatier::Cell::BOMBMORTAR:
116  m_mortarTimer = new QTimer;
117  m_mortarTimer->setSingleShot(true);
118  m_mortarTimer->setInterval(1500);
119  m_mortarTimer->start();
120  m_detonationCountdownTimer->stop();
121  m_mortarState = 0;
122  updateMortarState();
123  break;
124  case Granatier::Cell::HOLE:
125  if(!m_falling)
126  {
127  m_falling = true;
128  m_type = Granatier::Element::NONE;
129  m_detonationCountdownTimer->stop();
130  emit falling();
131  emit releaseBombArmory();
132  }
133  break;
134  default:
135  break;
136  }
137  }
138 
139  if(m_xSpeed != 0 || m_ySpeed != 0)
140  {
141  bool bOnCenter = false;
142  int xDirection = 0;
143  int xDeltaCenter = Granatier::CellSize/2 - (m_x - currentCol * Granatier::CellSize);
144  bool bMoveAwayFromCenter = false;
145  bool bIsHurdleCurrentCell = false;
146  bool bIsHurdleNextCell = false;
147 
148  if (m_xSpeed > 0)
149  {
150  xDirection = 1;
151  }
152  else if (m_xSpeed < 0)
153  {
154  xDirection = -1;
155  }
156  int yDirection = 0;
157  int yDeltaCenter = Granatier::CellSize/2 - (m_y - currentRow * Granatier::CellSize);
158  if (m_ySpeed > 0)
159  {
160  yDirection = 1;
161  }
162  else if (m_ySpeed < 0)
163  {
164  yDirection = -1;
165  }
166 
167  if((xDirection != 0 && xDeltaCenter == 0) || (yDirection != 0 && yDeltaCenter == 0))
168  {
169  bOnCenter = true;
170  }
171 
172  int newRow = m_arena->getRowFromY(m_y + m_ySpeed);
173  int newCol = m_arena->getColFromX(m_x + m_xSpeed);
174  int nextRow;
175  int nextCol;
176  if(xDirection > 0 || yDirection > 0)
177  {
178  nextRow = m_arena->getRowFromY(m_y + yDirection * Granatier::CellSize/2); //this is needed because the bombs won't move if they are coming from the top, hit an up arrow and there is a hurdle below the arrow
179  nextCol = m_arena->getColFromX(m_x + xDirection * Granatier::CellSize/2);
180  }
181  else
182  {
183  nextRow = m_arena->getRowFromY(m_y + m_ySpeed + yDirection * Granatier::CellSize/2);
184  nextCol = m_arena->getColFromX(m_x + m_xSpeed + xDirection * Granatier::CellSize/2);
185  }
186 
187  bIsHurdleCurrentCell = !(m_arena->getCell(currentRow, currentCol).isWalkable(this));
188  bIsHurdleNextCell = !(m_arena->getCell(nextRow, nextCol).isWalkable(this));
189 
190  if(xDirection * xDeltaCenter <= 0 || yDirection * yDeltaCenter <= 0)
191  {
192  bMoveAwayFromCenter = true;
193  }
194 
195  //at first, check if move over cell center or currently on cell center
196  if((bOnCenter || (xDirection * xDeltaCenter < 0 && xDirection * (m_xSpeed + xDeltaCenter) >= 0) || (yDirection * yDeltaCenter < 0 && yDirection * (m_ySpeed + yDeltaCenter) >= 0)) && m_mortarState < 0)
197  {
198  bool bIsMortar = false;
199  bool bIsNewDirection = false;
200 
201  switch (m_arena->getCell(currentRow, currentCol).getType())
202  {
203  case Granatier::Cell::ARROWUP:
204  if(yDirection != -1)
205  {
206  bIsNewDirection = true;
207  bMoveAwayFromCenter = true;
208  }
209  break;
210  case Granatier::Cell::ARROWRIGHT:
211  if(xDirection != 1)
212  {
213  bIsNewDirection = true;
214  bMoveAwayFromCenter = true;
215  }
216  break;
217  case Granatier::Cell::ARROWDOWN:
218  if(yDirection != 1)
219  {
220  bIsNewDirection = true;
221  bMoveAwayFromCenter = true;
222  }
223  break;
224  case Granatier::Cell::ARROWLEFT:
225  if(xDirection != -1)
226  {
227  bIsNewDirection = true;
228  bMoveAwayFromCenter = true;
229  }
230  break;
231  case Granatier::Cell::BOMBMORTAR:
232  bIsMortar = true;
233  break;
234  case Granatier::Cell::HOLE:
235  m_stopOnCenter = true;
236  break;
237  default:
238  break;
239  }
240 
241  //if two bombs move towards them, stop them and move them to the next cell center
242  if(((bIsHurdleCurrentCell && !bMoveAwayFromCenter) || bIsHurdleNextCell) && !m_stopOnCenter)
243  {
244  if(bOnCenter)
245  {
246  setXSpeed(0);
247  setYSpeed(0);
248  }
249  else
250  {
251  m_stopOnCenter = true;
252  setXSpeed(-m_xSpeed);
253  setYSpeed(-m_ySpeed);
254  }
255  }
256 
257  //stop at cell center if direction change or bomb mortar in current cell
258  else if(bIsMortar || bIsNewDirection || m_stopOnCenter)
259  {
260  move((currentCol+0.5) * Granatier::CellSize, (currentRow+0.5) * Granatier::CellSize);
261  setXSpeed(0);
262  setYSpeed(0);
263  m_stopOnCenter = false;
264  }
265  else
266  {
267  if((newRow != currentRow || newCol != currentCol) && m_mortarState < 0)
268  {
269  m_arena->removeCellElement(currentRow, currentCol, this);
270  m_arena->setCellElement(newRow, newCol, this);
271  }
272  move(m_x + m_xSpeed, m_y + m_ySpeed);
273  }
274  }
275  else
276  {
277  //if two bombs move towards them, stop them and move them to the next cell center
278  if(((bIsHurdleCurrentCell && !bMoveAwayFromCenter) || bIsHurdleNextCell) && !m_stopOnCenter && m_mortarState < 0)
279  {
280  if(bOnCenter)
281  {
282  setXSpeed(0);
283  setYSpeed(0);
284  }
285  else
286  {
287  m_stopOnCenter = true;
288  setXSpeed(-m_xSpeed);
289  setYSpeed(-m_ySpeed);
290  }
291  }
292  else
293  {
294  if((newRow != currentRow || newCol != currentCol) && m_mortarState < 0)
295  {
296  m_arena->removeCellElement(currentRow, currentCol, this);
297  m_arena->setCellElement(newRow, newCol, this);
298  }
299  move(m_x + m_xSpeed, m_y + m_ySpeed);
300  }
301  }
302  }
303 
304  if(m_mortarState >= 0 && !(m_mortarTimer->isActive()))
305  {
306  updateMortarState();
307  }
308 }
309 
310 void Bomb::move(qreal x, qreal y)
311 {
312  // Move the Bomb
313  m_x = x;
314  m_y = y;
315  emit(moved(m_x, m_y));
316 }
317 
318 qreal Bomb::getXSpeed() const
319 {
320  return m_xSpeed;
321 }
322 
323 qreal Bomb::getYSpeed() const
324 {
325  return m_ySpeed;
326 }
327 
328 qreal Bomb::getSpeed()
329 {
330  return m_speed;
331 }
332 
333 void Bomb::setXSpeed(qreal p_xSpeed)
334 {
335  m_xSpeed = p_xSpeed;
336 }
337 
338 void Bomb::setYSpeed(qreal p_ySpeed)
339 {
340  m_ySpeed = p_ySpeed;
341 }
342 
343 void Bomb::setThrown(int nDirection)
344 {
345  if(!m_mortarTimer)
346  {
347  m_mortarTimer = new QTimer;
348  m_mortarTimer->setSingleShot(true);
349  if(m_detonationCountdownTimer)
350  {
351  m_detonationCountdownTimer->stop();
352  }
353  }
354  qreal fSpeed = 2 * Granatier::CellSize / (Granatier::FPS * 800 / 1000.0 + 1);
355  switch(nDirection)
356  {
357  case Granatier::Direction::NORTH:
358  setXSpeed(0);
359  setYSpeed(-fSpeed);
360  break;
361  case Granatier::Direction::EAST:
362  setXSpeed(fSpeed);
363  setYSpeed(0);
364  break;
365  case Granatier::Direction::SOUTH:
366  setXSpeed(0);
367  setYSpeed(fSpeed);
368  break;
369  case Granatier::Direction::WEST:
370  setXSpeed(-fSpeed);
371  setYSpeed(0);
372  break;
373  }
374 
375  int curCellRow = m_arena->getRowFromY(m_y);
376  int curCellCol = m_arena->getColFromX(m_x);
377  m_arena->removeCellElement(curCellRow, curCellCol, this);
378 
379  m_type = Granatier::Element::NONE;
380  m_thrown = true;
381  m_mortarState = nMortarRampEnd;
382 }
383 
384 void Bomb::setKicked(int nDirection)
385 {
386  switch(nDirection)
387  {
388  case Granatier::Direction::NORTH:
389  setXSpeed(0);
390  setYSpeed(-5);
391  break;
392  case Granatier::Direction::EAST:
393  setXSpeed(5);
394  setYSpeed(0);
395  break;
396  case Granatier::Direction::SOUTH:
397  setXSpeed(0);
398  setYSpeed(5);
399  break;
400  case Granatier::Direction::WEST:
401  setXSpeed(-5);
402  setYSpeed(0);
403  break;
404  }
405 }
406 
407 bool Bomb::onCenter()
408 {
409  // Get the current cell center coordinates
410  qreal centerX = (m_arena->getColFromX(m_x) + 0.5) * Granatier::CellSize;
411  qreal centerY = (m_arena->getRowFromY(m_y) + 0.5) * Granatier::CellSize;
412  bool willGoPast = false;
413 
414  // Will the character go past the center of the cell it's on ?
415  // If goes right
416  if (m_xSpeed > 0) {
417  willGoPast = (m_x <= centerX && m_x + m_xSpeed >= centerX);
418  }
419  // If goes left
420  else if (m_xSpeed < 0) {
421  willGoPast = (m_x >= centerX && m_x + m_xSpeed <= centerX);
422  }
423  // If goes down
424  else if (m_ySpeed > 0) {
425  willGoPast = (m_y <= centerY && m_y + m_ySpeed >= centerY);
426  }
427  // If goes up
428  else if (m_ySpeed < 0) {
429  willGoPast = (m_y >= centerY && m_y + m_ySpeed <= centerY);
430  }
431  // If does not move
432  else {
433  willGoPast = (m_x == centerX && m_y == centerY);
434  }
435 
436  return willGoPast;
437 }
438 
439 void Bomb::moveOnCenter()
440 {
441  setX((m_arena->getColFromX(m_x) + 0.5) * Granatier::CellSize);
442  setY((m_arena->getRowFromY(m_y) + 0.5) * Granatier::CellSize);
443 }
444 
445 int Bomb::bombPower()
446 {
447  return m_bombPower;
448 }
449 
450 void Bomb::setBombPower(int bombPower)
451 {
452  m_bombPower = bombPower;
453 }
454 
455 void Bomb::pause()
456 {
457  if(m_detonationCountdownTimer)
458  {
459  m_detonationCountdownTimer->stop();
460  }
461 }
462 
463 void Bomb::resume()
464 {
465  if(m_detonationCountdownTimer)
466  {
467  m_detonationCountdownTimer->start();
468  }
469 }
470 
471 void Bomb::detonate()
472 {
473  if(!m_detonated)
474  {
475  m_detonated = true;
476  delete m_detonationCountdownTimer;
477  m_detonationCountdownTimer = 0;
478  emit bombDetonated(this);
479  emit releaseBombArmory();
480  }
481 }
482 
483 bool Bomb::isDetonated()
484 {
485  return m_detonated;
486 }
487 
488 int Bomb::explosionID()
489 {
490  return m_explosionID;
491 }
492 
493 void Bomb::initDetonation(int nBombID, int nDetonationTimeout)
494 {
495  if(m_bombID == m_explosionID)
496  {
497  m_explosionID = nBombID;
498  }
499 
500  if((!m_detonationCountdownTimer))
501  {
502  return;
503  }
504 
505  if(m_detonationCountdownTimer->interval() > nDetonationTimeout)
506  {
507  m_detonationCountdownTimer->setInterval(nDetonationTimeout);
508  }
509 
510  if(!(m_detonationCountdownTimer->isActive()))
511  {
512  m_detonationCountdownTimer->start();
513  }
514 }
515 
516 void Bomb::slot_detonationCompleted()
517 {
518  //TODO: call from game
519  m_arena->removeCellElement(m_arena->getRowFromY(m_y), m_arena->getColFromX(m_x), this);
520 }
521 
522 void Bomb::updateMortarState()
523 {
524  emit mortar(m_mortarState, nMortarRampEnd, nMortarPeak, nMortarGround);
525 
526  if(m_mortarState <= 0)
527  {
528  int curCellRow = m_arena->getRowFromY(m_y);
529  int curCellCol = m_arena->getColFromX(m_x);
530 
531  setXSpeed(0);
532  setYSpeed(0);
533 
534  m_thrown = false;
535  m_type = Granatier::Element::NONE;
536  m_arena->removeCellElement(curCellRow, curCellCol, this);
537  }
538  else if(m_mortarState == nMortarRampEnd)
539  {
540  int curCellRow = m_arena->getRowFromY(m_y);
541  int curCellCol = m_arena->getColFromX(m_x);
542 
543  if(!m_thrown)
544  {
545  int nRow;
546  int nCol;
547  bool bFound = false;
548 
549  do
550  {
551  nRow = m_arena->getNbRows() * (qrand()/1.0)/RAND_MAX;
552  nCol = m_arena->getNbColumns() * (qrand()/1.0)/RAND_MAX;
553  if(m_arena->getCell(nRow, nCol).getType() != Granatier::Cell::WALL)
554  {
555  bFound = true;
556  }
557  }
558  while (!bFound);
559 
560  setXSpeed((nCol - curCellCol) * Granatier::CellSize / (Granatier::FPS * 800 / 1000.0));
561  setYSpeed((nRow - curCellRow) * Granatier::CellSize / (Granatier::FPS * 800 / 1000.0));
562  }
563 
564  m_type = Granatier::Element::NONE;
565  m_arena->removeCellElement(curCellRow, curCellCol, this);
566  }
567  else if(m_mortarState == nMortarGround)
568  {
569  setXSpeed(0);
570  setYSpeed(0);
571  }
572  else if (m_mortarState > nMortarGround)
573  {
574  int curCellRow = m_arena->getRowFromY(m_y);
575  int curCellCol = m_arena->getColFromX(m_x);
576  m_type = Granatier::Element::BOMB;
577  m_arena->setCellElement(curCellRow, curCellCol, this);
578 
579  m_mortarState = -1;
580  if(m_detonationCountdownTimer)
581  {
582  if(!m_thrown)
583  {
584  initDetonation(m_bombID, 40);
585  }
586  else
587  {
588  m_detonationCountdownTimer->setInterval(2000);
589  m_detonationCountdownTimer->start();
590  }
591  }
592  }
593 
594  if(m_mortarState >= 0)
595  {
596  m_mortarState++;
597  }
598 }
Bomb::m_detonated
bool m_detonated
The Bomb detonation has already started.
Definition: bomb.h:47
QTimer::setInterval
void setInterval(int msec)
Bomb::getXSpeed
qreal getXSpeed() const
Gets the Bomb x-speed value.
Definition: bomb.cpp:318
Element::m_type
Granatier::Element::Type m_type
The Element type.
Definition: element.h:39
Element::m_x
qreal m_x
The Element current x-coordinate.
Definition: element.h:48
Bomb::falling
void falling()
Emitted when the bomb is falling in a hole.
Element::m_y
qreal m_y
The Element current y-coordinate.
Definition: element.h:51
Bomb::goUp
void goUp()
Makes the Bomb go up.
Definition: bomb.cpp:73
Bomb::mortar
void mortar(int nMortarState, int nMortarRampEnd, int nMortarPeak, int nMortarGround)
Emitted when the Bomb is thrown by the mortar or by the player.
Arena::setCellElement
void setCellElement(const int p_row, const int p_column, Element *p_element)
Sets the Element that is on the Cell whose coordinates are given in parameters.
Definition: arena.cpp:72
nMortarGround
const int nMortarGround
Definition: bomb.cpp:29
Element::setY
void setY(qreal p_y)
Sets the Element y-coordinate to the given value.
Definition: element.cpp:62
Granatier::FPS
const int FPS
The Frames Per Second for the game.
Definition: granatierglobals.h:28
Bomb::setBombPower
void setBombPower(int bombPower)
Sets the Power of the bomb.
Definition: bomb.cpp:450
Bomb::m_speed
qreal m_speed
The Bomb speed.
Definition: bomb.h:44
Bomb::detonate
void detonate()
Manages the Bomb explosion.
Definition: bomb.cpp:471
Bomb::m_mortarState
int m_mortarState
Definition: bomb.h:64
Bomb::getYSpeed
qreal getYSpeed() const
Gets the Bomb y-speed value.
Definition: bomb.cpp:323
Arena::getNbColumns
int getNbColumns() const
Gets the number of columns of the Arena.
Definition: arena.cpp:164
Granatier::Cell::ARROWDOWN
Definition: granatierglobals.h:80
Bomb::Bomb
Bomb(qreal fX, qreal fY, Arena *p_arena, int nBombID, int nDetonationCountdown)
Creates a new Bomb instance.
Definition: bomb.cpp:31
Bomb::m_stopOnCenter
bool m_stopOnCenter
Definition: bomb.h:67
Bomb::moveOnCenter
void moveOnCenter()
Moves the Bomb on the center of its current Cell.
Definition: bomb.cpp:439
nMortarRampEnd
const int nMortarRampEnd
Definition: bomb.cpp:27
Bomb::goDown
void goDown()
Makes the Bomb go down.
Definition: bomb.cpp:77
Bomb::setKicked
void setKicked(int nDirection)
The direction to move.
Definition: bomb.cpp:384
Element::setX
void setX(qreal p_x)
Sets the Element x-coordinate to the given value.
Definition: element.cpp:56
Bomb::m_explosionID
int m_explosionID
The ID of the Bomb that causes the explosion.
Definition: bomb.h:56
Bomb::initDetonation
void initDetonation(int nBombID, int nDetonationTimeout)
sets the explosion ID and detonation countdown
Definition: bomb.cpp:493
Arena::removeCellElement
void removeCellElement(const int p_row, const int p_column, Element *p_element)
Removes the Element that is on the Cell whose coordinates are given in parameters.
Definition: arena.cpp:81
Bomb::m_bombID
int m_bombID
The Bomb ID.
Definition: bomb.h:53
Bomb::m_thrown
bool m_thrown
Definition: bomb.h:66
Bomb::getSpeed
qreal getSpeed()
Gets the Bomb speed.
Definition: bomb.cpp:328
Bomb::onCenter
bool onCenter()
Checks the Bomb gets on a Cell center during its next movement.
Definition: bomb.cpp:407
Element::m_xInit
qreal m_xInit
The Element initial x-coordinate.
Definition: element.h:42
Bomb::m_falling
bool m_falling
Definition: bomb.h:69
Element::moved
void moved(qreal p_x, qreal p_y)
Emitted on Element move.
Bomb::m_mortarTimer
QTimer * m_mortarTimer
Timer used for the throw bonus and mortar.
Definition: bomb.h:62
Granatier::CellSize
const qreal CellSize
The Cell size.
Definition: granatierglobals.h:31
Granatier::Cell::ARROWRIGHT
Definition: granatierglobals.h:82
QTimer
Granatier::Direction::WEST
Definition: granatierglobals.h:129
Bomb::goRight
void goRight()
Makes the Bomb go to the right.
Definition: bomb.cpp:81
Element::m_arena
Arena * m_arena
The Arena the Element is on.
Definition: element.h:54
Bomb::m_detonationCountdownTimer
QTimer * m_detonationCountdownTimer
Timer used to make the bomb detonate.
Definition: bomb.h:59
Bomb::m_xSpeed
qreal m_xSpeed
The Bomb x-speed.
Definition: bomb.h:38
Bomb::bombDetonated
void bombDetonated(Bomb *bomb)
Emitted when the Bomb is exploded.
Bomb::updateMortarState
void updateMortarState()
Definition: bomb.cpp:522
nMortarPeak
const int nMortarPeak
Definition: bomb.cpp:28
Arena
This class represents the Arena of the game.
Definition: arena.h:36
Granatier::Cell::WALL
Definition: granatierglobals.h:75
Granatier::Element::NONE
Definition: granatierglobals.h:91
Bomb::isDetonated
bool isDetonated()
Definition: bomb.cpp:483
Bomb::setThrown
void setThrown(int nDirection)
The direction to throw.
Definition: bomb.cpp:343
Bomb::m_bombPower
int m_bombPower
The Bomb detonation power.
Definition: bomb.h:50
Element
This class describes the common characteristics and behaviour of any game Element (character or item)...
Definition: element.h:32
Granatier::Element::BOMB
Definition: granatierglobals.h:94
Granatier::Direction::NORTH
Definition: granatierglobals.h:126
Bomb::explosionID
int explosionID()
Definition: bomb.cpp:488
Bomb::releaseBombArmory
void releaseBombArmory()
Emitted to refill the player bomb armory.
QTimer::stop
void stop()
Bomb::bombPower
int bombPower()
Power of the bomb.
Definition: bomb.cpp:445
Bomb::m_ySpeed
qreal m_ySpeed
The Bomb y-speed.
Definition: bomb.h:41
Bomb::pause
void pause()
Pauses bomb timer.
Definition: bomb.cpp:455
Bomb::resume
void resume()
Resumes bomb timer.
Definition: bomb.cpp:463
Arena::getColFromX
int getColFromX(const qreal p_x) const
Gets the column index corresponding to the given x-coordinate.
Definition: arena.cpp:154
Bomb::updateMove
void updateMove()
Updates the Bomb move.
Definition: bomb.cpp:89
Granatier::Cell::ARROWUP
Definition: granatierglobals.h:79
Cell::isWalkable
bool isWalkable(Element *p_element) const
Returns if it is possible to move into the cell or not, because of a wall, bomb, etc.
Definition: cell.cpp:30
Bomb::~Bomb
~Bomb()
Deletes the Bomb instance.
Definition: bomb.cpp:67
Element::m_yInit
qreal m_yInit
The Element initial y-coordinate.
Definition: element.h:45
Granatier::Direction::EAST
Definition: granatierglobals.h:128
arena.h
Bomb::setXSpeed
void setXSpeed(qreal p_xSpeed)
Set the Bomb x-speed value.
Definition: bomb.cpp:333
QTimer::start
void start(int msec)
Bomb::move
void move(qreal x, qreal y)
Moves the Bomb function of its current coordinates and speed.
Definition: bomb.cpp:310
Bomb::slot_detonationCompleted
void slot_detonationCompleted()
Definition: bomb.cpp:516
Bomb::goLeft
void goLeft()
Makes the Bomb go to the left.
Definition: bomb.cpp:85
QTimer::isActive
bool isActive() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Granatier::Cell::BOMBMORTAR
Definition: granatierglobals.h:78
Granatier::Cell::ARROWLEFT
Definition: granatierglobals.h:81
Granatier::Cell::HOLE
Definition: granatierglobals.h:73
Arena::getNbRows
int getNbRows() const
Gets the number of rows of the Arena.
Definition: arena.cpp:169
bomb.h
Cell::getType
Granatier::Cell::Type getType() const
Gets the Cell type.
Definition: cell.cpp:52
Arena::getCell
Cell getCell(const int p_row, const int p_column) const
Gets the Cell at the given coordinates.
Definition: arena.cpp:120
Granatier::Direction::SOUTH
Definition: granatierglobals.h:127
Arena::getRowFromY
int getRowFromY(const qreal p_y) const
Gets the row index corresponding to the given y-coordinate.
Definition: arena.cpp:144
QTimer::setSingleShot
void setSingleShot(bool singleShot)
Bomb::setYSpeed
void setYSpeed(qreal p_ySpeed)
Set the Bomb y-speed value.
Definition: bomb.cpp:338
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

KDE's Doxygen guidelines are available online.

granatier

Skip menu "granatier"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal