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

kgoldrunner

  • sources
  • kde-4.14
  • kdegames
  • kgoldrunner
  • src
kgrscene.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright 2012 Roney Gomes <roney477@gmail.com> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16  ****************************************************************************/
17 
18 #include <QDebug>
19 #include <kdebug.h>
20 
21 #include <KLocalizedString>
22 
23 #include <QFont>
24 #include <QTimeLine>
25 
26 #include "kgrview.h"
27 #include "kgrscene.h"
28 #include "kgrsprite.h"
29 #include "kgrrenderer.h"
30 
31 const StartFrame animationStartFrames [nAnimationTypes] = {
32  RIGHTWALK1, LEFTWALK1, RIGHTCLIMB1, LEFTCLIMB1,
33  CLIMB1, CLIMB1, FALL1, FALL2,
34  DIGBRICK1, // Start frame for OPEN_BRICK.
35  DIGBRICK6}; // Start frame for CLOSE_BRICK.
36 
37 KGrScene::KGrScene (KGrView * view)
38  :
39  QGraphicsScene (view),
40  // Allow FIELDWIDTH * FIELDHEIGHT tiles for the KGoldruner level-layouts,
41  // plus 2 more tile widths all around for text areas, frame and spillover
42  // for mouse actions (to avoid accidental clicks affecting the desktop).
43  m_view (view),
44  m_background (0),
45  m_level (1),
46  m_title (0),
47  m_replayMessage (0),
48  m_livesText (0),
49  m_scoreText (0),
50  m_hasHintText (0),
51  m_pauseResumeText (0),
52  m_heroId (0),
53  m_tilesWide (FIELDWIDTH + 2 * 2),
54  m_tilesHigh (FIELDHEIGHT + 2 * 2),
55  m_tileSize (10),
56  m_toolbarTileSize (10),
57  m_themeChanged (true),
58  m_topLeftX (0),
59  m_topLeftY (0),
60  m_mouse (new QCursor()),
61  m_fadingTimeLine (new QTimeLine (1000, this))
62 {
63  setItemIndexMethod(NoIndex);
64 
65  m_tiles.fill (0, m_tilesWide * m_tilesHigh);
66  m_tileTypes.fill (FREE, m_tilesWide * m_tilesHigh);
67 
68  m_renderer = new KGrRenderer (this);
69 
70  m_frame = addRect (0, 0, 100, 100); // Create placeholder for frame.
71  m_frame->setVisible (false);
72 
73  m_spotlight = addRect (0, 0, 100, 100); // Create placeholder for spot.
74  m_spotlight->setVisible (false);
75 
76  m_title = new QGraphicsSimpleTextItem();
77  addItem (m_title);
78 
79  m_replayMessage = new QGraphicsSimpleTextItem();
80  addItem (m_replayMessage);
81  m_replayMessage->setVisible (false); // Visible only in demo/replay.
82 
83  m_livesText = new QGraphicsSimpleTextItem();
84  addItem (m_livesText);
85 
86  m_scoreText = new QGraphicsSimpleTextItem();
87  addItem (m_scoreText);
88 
89  m_hasHintText = new QGraphicsSimpleTextItem();
90  addItem (m_hasHintText);
91 
92  m_pauseResumeText = new QGraphicsSimpleTextItem();
93  addItem (m_pauseResumeText);
94 
95  m_fadingTimeLine->setCurveShape (QTimeLine::EaseOutCurve);
96  m_fadingTimeLine->setUpdateInterval (50);
97  connect (m_fadingTimeLine, SIGNAL (valueChanged(qreal)),
98  this, SLOT (drawSpotlight(qreal)));
99  connect (m_fadingTimeLine, SIGNAL (finished()),
100  this, SIGNAL (fadeFinished()));
101 }
102 
103 KGrScene::~KGrScene()
104 {
105  delete m_mouse;
106  delete m_fadingTimeLine;
107 }
108 
109 void KGrScene::redrawScene ()
110 {
111  qDebug() << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged;
112  bool redrawToolbar = false;
113  if (m_sizeChanged) {
114  // Calculate what size of tile will fit in the view.
115  QSize size = m_view->size();
116  int tileSize = qMin (size.width() / m_tilesWide,
117  size.height() / m_tilesHigh);
118  m_topLeftX = (size.width() - m_tilesWide * tileSize)/2.0;
119  m_topLeftY = (size.height() - m_tilesHigh * tileSize)/2.0;
120  setSceneRect (0, 0, size.width(), size.height());
121  qDebug() << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize;
122 
123  // Make the fade-out/fade-in rectangle cover the playing area.
124  m_spotlight->setRect (m_topLeftX + 2 * tileSize - 1,
125  m_topLeftY + 2 * tileSize - 1,
126  (m_tilesWide - 4) * tileSize + 2,
127  (m_tilesHigh - 4) * tileSize + 2);
128  m_maxRadius = (5 * m_spotlight->rect().width() + 4) / 8;
129  m_spotlight->setPen (Qt::NoPen);
130  m_spotlight->setZValue (10);
131  m_spotlight->setVisible (false);
132 
133  // Set up the gradient to draw the spotlight (black with a hole in it).
134  QPointF center (width() * 0.5, height() * 0.5);
135  m_gradient.setCenter (center);
136  m_gradient.setFocalPoint (center);
137  m_gradient.setRadius (m_maxRadius);
138  m_gradient.setColorAt (1.00, QColor (0, 0, 0, 255));
139  m_gradient.setColorAt (0.85, QColor (0, 0, 0, 0));
140 
141  int index = 0;
142  foreach (KGameRenderedItem * tile, m_tiles) {
143  if (tile) {
144  setTile (tile, tileSize, index/m_tilesHigh, index%m_tilesHigh);
145  }
146  index++;
147  }
148  foreach (KGrSprite * sprite, m_sprites) {
149  if (sprite) {
150  sprite->changeCoordinateSystem
151  (m_topLeftX, m_topLeftY, tileSize);
152  }
153  }
154 
155  if (m_tileSize != tileSize) {
156  // Do not expand the toolbar (in edit mode) until there is room for
157  // it. This avoids a nasty expand-contract-expand-contract loop.
158  m_toolbarTileSize = ((tileSize > m_tileSize) && (m_topLeftY == 0)) ?
159  m_tileSize : tileSize;
160  }
161  // When conditions are right, redraw editing icons, if in edit mode.
162  redrawToolbar = ((m_toolbarTileSize != m_tileSize) &&
163  (m_topLeftY > 0)) ? true : false;
164  m_tileSize = tileSize;
165  m_sizeChanged = false;
166  }
167 
168  // Re-draw text, background and frame if either scene-size or theme changes.
169 
170  // Resize and draw texts for title, score, lives, hasHint and pauseResume.
171  setTextFont (m_title, 0.6);
172  setTitle (m_title->text());
173  placeTextItems();
174 
175  // Resize and draw different backgrounds, depending on the level and theme.
176  loadBackground (m_level);
177 
178  if (m_renderer->hasBorder()) {
179  // There are border tiles in the theme, so do not draw a frame.
180  m_frame->setVisible (false);
181  }
182  else {
183  // There are no border tiles, so draw a frame around the board.
184  drawFrame();
185  }
186 
187  if (m_themeChanged) {
188  // Fill the scene (and view) with the new background color. Do this
189  // even if the background has no border, to avoid ugly white rectangles
190  // appearing if rendering and painting is momentarily a bit slow.
191  setBackgroundBrush (m_renderer->borderColor());
192 
193  // Erase border tiles (if any) and draw new ones, if new theme has them.
194  drawBorder();
195 
196  // Redraw all the tiles, except for borders and tiles of type FREE.
197  for (int i = 1; i <= FIELDWIDTH; i++) {
198  for (int j = 1; j <= FIELDHEIGHT; j++) {
199  int index = i * m_tilesHigh + j;
200  paintCell (i, j, m_tileTypes[index]);
201  }
202  }
203 
204  // Redraw editing icons if theme changes when in edit mode.
205  redrawToolbar = true;
206  m_themeChanged = false;
207  }
208 
209  if (redrawToolbar) {
210  m_toolbarTileSize = m_tileSize; // If game is in edit mode, KGoldrunner
211  emit redrawEditToolbar(); // object redraws the editToolbar.
212  }
213 }
214 
215 void KGrScene::changeTheme()
216 {
217  m_themeChanged = true;
218  redrawScene();
219 }
220 
221 void KGrScene::changeSize()
222 {
223  m_sizeChanged = true;
224  redrawScene();
225 }
226 
227 void KGrScene::setTitle (const QString & newTitle)
228 {
229  if (! m_title) return;
230 
231  m_title->setText (newTitle);
232  QRectF r = m_title->boundingRect(); // Centre the title.
233  m_title->setPos ((sceneRect().width() - r.width())/2,
234  m_topLeftY + (m_tileSize - r.height())/2);
235 }
236 
237 void KGrScene::setReplayMessage (const QString & msg)
238 {
239  m_replayMessage->setText (msg);
240 }
241 
242 void KGrScene::showReplayMessage (bool onOff)
243 {
244  m_replayMessage->setVisible (onOff);
245 }
246 
247 void KGrScene::placeTextItems()
248 {
249  setTextFont (m_replayMessage, 0.5);
250  setTextFont (m_livesText, 0.5);
251  setTextFont (m_scoreText, 0.5);
252  setTextFont (m_hasHintText, 0.5);
253  setTextFont (m_pauseResumeText, 0.5);
254 
255  QRectF r = m_replayMessage->boundingRect();
256  m_replayMessage->setPos ((sceneRect().width() - r.width())/2,
257  m_topLeftY + 1.4 * m_tileSize - 0.5 * r.height());
258  m_replayMessage->setZValue (10);
259 
260  qreal totalWidth = 0.0;
261  r = m_livesText->boundingRect();
262  qreal x = m_topLeftX + 2 * m_tileSize;
263  qreal y = sceneRect().height() - m_topLeftY - (m_tileSize + r.height())/2;
264 
265  m_livesText->setPos (x, y);
266  totalWidth += r.width();
267 
268  r = m_scoreText->boundingRect();
269  m_scoreText->setPos (x + totalWidth, y);
270  totalWidth += r.width();
271 
272  r = m_hasHintText->boundingRect();
273  m_hasHintText->setPos (x + totalWidth, y);
274  totalWidth += r.width();
275 
276  r = m_pauseResumeText->boundingRect();
277  m_pauseResumeText->setPos (x + totalWidth, y);
278  totalWidth += r.width();
279 
280  qreal spacing = ((m_tilesWide - 4) * m_tileSize - totalWidth) / 3.0;
281  if (spacing < 0.0)
282  return;
283 
284  m_scoreText->moveBy (spacing, 0.0);
285  m_hasHintText->moveBy (2.0 * spacing, 0.0);
286  m_pauseResumeText->moveBy (3.0 * spacing, 0.0);
287 }
288 
289 void KGrScene::showLives (long lives)
290 {
291  if (m_livesText)
292  m_livesText->setText (i18n("Lives: %1", QString::number(lives)
293  .rightJustified(3, '0')));
294 }
295 
296 void KGrScene::showScore (long score)
297 {
298  if (m_scoreText)
299  m_scoreText->setText (i18n("Score: %1", QString::number(score)
300  .rightJustified(7, '0')));
301 }
302 
303 void KGrScene::setHasHintText (const QString & msg)
304 {
305  if (m_hasHintText)
306  m_hasHintText->setText (msg);
307 }
308 
309 void KGrScene::setPauseResumeText (const QString & msg)
310 {
311  if (m_pauseResumeText)
312  m_pauseResumeText->setText (msg);
313 }
314 
315 void KGrScene::goToBlack()
316 {
317  drawSpotlight (0);
318 }
319 
320 void KGrScene::fadeIn (bool inOut)
321 {
322  // For fade-in, inOut = true, circle opens, from 0.0 to 1.0.
323  // For fade-out, inOut = false, circle closes, from 1.0 to 0.0.
324  m_fadingTimeLine->setDirection (inOut ? QTimeLine::Forward
325  : QTimeLine::Backward);
326  m_fadingTimeLine->start();
327 }
328 
329 void KGrScene::drawSpotlight (qreal ratio)
330 {
331  if (ratio > 0.99) {
332  m_spotlight->setVisible (false); // End of the close-open cycle.
333  return;
334  }
335  else if (ratio <= 0.01) {
336  m_spotlight->setBrush (Qt::black);
337  }
338  else {
339  m_gradient.setRadius (ratio * m_maxRadius);
340  m_spotlight->setBrush (QBrush (m_gradient));
341  }
342 
343  m_spotlight->setVisible (true);
344 }
345 
346 void KGrScene::setLevel (unsigned int level)
347 {
348  if (level == m_level) {
349  return;
350  }
351  m_level = level;
352  loadBackground (level); // Load background for level.
353 }
354 
355 void KGrScene::loadBackground (const int level)
356 {
357  // NOTE: The background picture can be the same size as the level-layout (as
358  // in the Egypt theme) OR it can be the same size as the entire viewport.
359  // In this example the background is fitted into the level-layout.
360  m_background = m_renderer->getBackground (level, m_background);
361 
362  m_background->setRenderSize (QSize ((m_tilesWide - 4) * m_tileSize,
363  (m_tilesHigh - 4) * m_tileSize));
364  m_background->setPos (m_topLeftX + 2 * m_tileSize,
365  m_topLeftY + 2 * m_tileSize);
366  // Keep the background behind the level layout.
367  m_background->setZValue (-1);
368 }
369 
370 void KGrScene::setTile (KGameRenderedItem * tile, const int tileSize,
371  const int i, const int j)
372 {
373  tile->setRenderSize (QSize (tileSize, tileSize));
374  tile->setPos (m_topLeftX + (i+1) * tileSize, m_topLeftY + (j+1) * tileSize);
375 }
376 
377 void KGrScene::setBorderTile (const QString spriteKey, const int x, const int y)
378 {
379  int index = x * m_tilesHigh + y;
380  KGameRenderedItem * t = m_renderer->getBorderItem (spriteKey,
381  m_tiles.at(index));
382  m_tiles[index] = t;
383 
384  if (t) {
385  setTile (t, m_tileSize, x, y);
386  }
387 }
388 
389 void KGrScene::drawBorder()
390 {
391  // Corners.
392  setBorderTile ("frame-topleft", 0, 0);
393  setBorderTile ("frame-topright", FIELDWIDTH + 1, 0);
394  setBorderTile ("frame-bottomleft", 0, FIELDHEIGHT + 1);
395  setBorderTile ("frame-bottomright", FIELDWIDTH + 1, FIELDHEIGHT + 1);
396 
397  // Upper side.
398  for (int i = 1; i <= FIELDWIDTH; i++)
399  setBorderTile ("frame-top", i, 0);
400 
401  // Lower side.
402  for (int i = 1; i <= FIELDWIDTH; i++)
403  setBorderTile ("frame-bottom", i, FIELDHEIGHT + 1);
404 
405  // Left side.
406  for (int i = 1; i <= FIELDHEIGHT; i++)
407  setBorderTile ("frame-left", 0, i);
408 
409  // Right side.
410  for (int i = 1; i <= FIELDHEIGHT; i++)
411  setBorderTile ("frame-right", FIELDWIDTH + 1, i);
412 }
413 
414 void KGrScene::drawFrame()
415 {
416  int w = 0.05 * m_tileSize + 0.5;
417  w = w < 1 ? 1 : w;
418  m_frame->setRect (
419  m_topLeftX + (2 * m_tileSize) - (3 * w),
420  m_topLeftY + (2 * m_tileSize) - (3 * w),
421  FIELDWIDTH * m_tileSize + 6 * w,
422  FIELDHEIGHT * m_tileSize + 6 * w);
423  kDebug() << "FRAME WIDTH" << w << "tile size" << m_tileSize << "rectangle" << m_frame->rect();
424  QPen pen = QPen (m_renderer->textColor());
425  pen.setWidth (w);
426  m_frame->setPen (pen);
427  m_frame->setVisible (true);
428 }
429 
430 void KGrScene::paintCell (const int i, const int j, const char type)
431 {
432  int index = i * m_tilesHigh + j;
433  KGameRenderedItem * t = m_renderer->getTileItem (type, m_tiles.at(index));
434  m_tiles[index] = t;
435  m_tileTypes[index] = type;
436 
437  if (t) {
438  setTile (t, m_tileSize, i, j);
439  }
440 }
441 
442 int KGrScene::makeSprite (const char type, int i, int j)
443 {
444  int spriteId;
445  KGrSprite * sprite = m_renderer->getSpriteItem (type, TickTime);
446 
447  if (m_sprites.count(0) > 0 &&
448  ((spriteId = m_sprites.lastIndexOf (0)) >= 0)) {
449  // Re-use a slot previously occupied by a transient member of the list.
450  m_sprites[spriteId] = sprite;
451  }
452  else {
453  // Otherwise, add to the end of the list.
454  spriteId = m_sprites.count();
455  m_sprites.append (sprite);
456  }
457 
458  int frame1 = animationStartFrames [FALL_L];
459 
460  switch (type) {
461  case HERO:
462  m_heroId = spriteId;
463  sprite->setZ (1);
464  break;
465  case ENEMY:
466  sprite->setZ (2);
467  break;
468  case BRICK:
469  frame1 = animationStartFrames [OPEN_BRICK];
470 
471  // The hero and enemies must be painted in front of dug bricks.
472  sprite->setZ (0);
473 
474  // Erase the brick-image so that animations are visible in all themes.
475  paintCell (i, j, FREE);
476  break;
477  default:
478  break;
479  }
480 
481  sprite->setFrame (frame1);
482  sprite->setCoordinateSystem (m_topLeftX, m_topLeftY, m_tileSize);
483  addItem (sprite); // The sprite can be correctly rendered now.
484  sprite->move (i, j, frame1);
485  return spriteId;
486 }
487 
488 void KGrScene::animate (bool missed)
489 {
490  foreach (KGrSprite * sprite, m_sprites) {
491  if (sprite != 0) {
492  sprite->animate (missed);
493  }
494  }
495 }
496 
497 void KGrScene::startAnimation (const int id, const bool repeating,
498  const int i, const int j, const int time,
499  const Direction dirn, const AnimationType type)
500 {
501  // TODO - Put most of this in helper code, based on theme parameters.
502  int dx = 0;
503  int dy = 0;
504  int frame = animationStartFrames [type];
505  int nFrames = 8;
506  int nFrameChanges = 4;
507 
508  switch (dirn) {
509  case RIGHT:
510  dx = +1;
511  break;
512  case LEFT:
513  dx = -1;
514  break;
515  case DOWN:
516  dy = +1;
517  if ((type == FALL_R) || (type == FALL_L)) {
518  nFrames = 1;
519  }
520  else {
521  nFrames = 2;
522  }
523  break;
524  case UP:
525  dy = -1;
526  nFrames = 2;
527  break;
528  case STAND:
529  switch (type) {
530  case OPEN_BRICK:
531  nFrames = 5;
532  break;
533  case CLOSE_BRICK:
534  nFrames = 4;
535  break;
536  default:
537  // Show a standing hero or enemy, using the previous StartFrame.
538  nFrames = 0;
539  break;
540  }
541  break;
542  default:
543  break;
544  }
545 
546  // TODO - Generalise nFrameChanges = 4, also the tick time = 20 new sprite.
547  m_sprites.at(id)->setAnimation (repeating, i, j, frame, nFrames, dx, dy,
548  time, nFrameChanges);
549 }
550 
551 void KGrScene::gotGold (const int spriteId, const int i, const int j,
552  const bool spriteHasGold, const bool lost)
553 {
554  // Hide collected gold or show dropped gold, but not if the gold was lost.
555  if (! lost) {
556  paintCell (i, j, (spriteHasGold) ? FREE : NUGGET);
557  }
558 
559  // If the rules allow, show whether or not an enemy sprite is carrying gold.
560  if (enemiesShowGold && (m_sprites.at(spriteId)->spriteType() == ENEMY)) {
561  m_sprites.at(spriteId)->setSpriteKey (spriteHasGold ? "gold_enemy"
562  : "enemy");
563  }
564 }
565 
566 void KGrScene::showHiddenLadders (const QList<int> & ladders, const int width)
567 {
568  foreach (int offset, ladders) {
569  int i = offset % width;
570  int j = offset / width;
571  paintCell (i, j, LADDER);
572  }
573 }
574 
575 void KGrScene::deleteSprite (const int spriteId)
576 {
577  QPointF loc = m_sprites.at(spriteId)->currentLoc();
578  bool brick = (m_sprites.at(spriteId)->spriteType() == BRICK);
579 
580  delete m_sprites.at(spriteId);
581  m_sprites [spriteId] = 0;
582 
583  if (brick) {
584  // Dug-brick sprite erased: restore the tile that was at that location.
585  paintCell (loc.x(), loc.y(), BRICK);
586  }
587 }
588 
589 void KGrScene::deleteAllSprites()
590 {
591  qDeleteAll(m_sprites);
592  m_sprites.clear();
593 }
594 
595 void KGrScene::preRenderSprites()
596 {
597  char type[2] = {HERO, ENEMY};
598  for (int t = 0; t < 2; t++) {
599  KGrSprite * sprite = m_renderer->getSpriteItem (type[t], TickTime);
600  sprite->setFrame (1);
601  sprite->setRenderSize (QSize (m_tileSize, m_tileSize));
602  int count = sprite->frameCount();
603 
604  // Pre-render all frames of the hero and an enemy, to avoid hiccups in
605  // animation during the first few seconds of KGoldrunner execution.
606  for (int n = 1; n <= count; n++) {
607  sprite->setFrame (n);
608  }
609  delete sprite;
610  }
611 }
612 
613 void KGrScene::setMousePos (const int i, const int j)
614 {
615  m_mouse->setPos (m_view->mapToGlobal (QPoint (
616  m_topLeftX + (i + 1) * m_tileSize + m_tileSize/2,
617  m_topLeftY + (j + 1) * m_tileSize + m_tileSize/2)));
618 }
619 
620 void KGrScene::getMousePos (int & i, int & j)
621 {
622  QPoint pos = m_view->mapFromGlobal (m_mouse->pos());
623  i = pos.x();
624  j = pos.y();
625  if (! m_view->isActiveWindow()) {
626  i = -2;
627  j = -2;
628  return;
629  }
630  // IDW TODO - Check for being outside scene. Use saved m_width and m_height.
631 
632  i = (i - m_topLeftX)/m_tileSize - 1;
633  j = (j - m_topLeftY)/m_tileSize - 1;
634 
635  // Make sure i and j are within the KGoldrunner playing area.
636  i = (i < 1) ? 1 : ((i > FIELDWIDTH) ? FIELDWIDTH : i);
637  j = (j < 1) ? 1 : ((j > FIELDHEIGHT) ? FIELDHEIGHT : j);
638 }
639 
640 void KGrScene::setTextFont (QGraphicsSimpleTextItem * t, double fontFraction)
641 {
642  QFont f;
643  f.setPixelSize ((int) (m_tileSize * fontFraction + 0.5));
644  f.setWeight (QFont::Bold);
645  f.setStretch (QFont::Expanded);
646  t->setBrush (m_renderer->textColor());
647  t->setFont (f);
648 }
649 
650 #include "kgrscene.moc"
LEFTWALK1
Definition: kgrscene.h:63
QList::clear
void clear()
OPEN_BRICK
Definition: kgrglobals.h:208
QGraphicsScene
KGrScene::getMousePos
void getMousePos(int &i, int &j)
Definition: kgrscene.cpp:620
KGrScene::redrawEditToolbar
void redrawEditToolbar()
QSize::width
int width() const
FALL_L
Definition: kgrglobals.h:207
KGrScene::showReplayMessage
void showReplayMessage(bool onOff)
Definition: kgrscene.cpp:242
KGrScene::setReplayMessage
void setReplayMessage(const QString &msg)
Definition: kgrscene.cpp:237
DIGBRICK6
Definition: kgrscene.h:73
KGrScene::fadeIn
void fadeIn(bool inOut)
Definition: kgrscene.cpp:320
QGraphicsItem::moveBy
void moveBy(qreal dx, qreal dy)
QGradient::setColorAt
void setColorAt(qreal position, const QColor &color)
TickTime
const int TickTime
Definition: kgrglobals.h:217
QFont
kgrrenderer.h
HERO
const char HERO
Definition: kgrglobals.h:31
QVector::fill
QVector< T > & fill(const T &value, int size)
QByteArray::fill
QByteArray & fill(char ch, int size)
QGraphicsScene::addRect
QGraphicsRectItem * addRect(const QRectF &rect, const QPen &pen, const QBrush &brush)
QList::at
const T & at(int i) const
QGraphicsScene::setBackgroundBrush
void setBackgroundBrush(const QBrush &brush)
KGrScene::tileSize
QSize tileSize() const
Get the current size of the squared region occupied by a single visual element (characters, ladders, bricks etc.).
Definition: kgrscene.h:121
KGrRenderer::textColor
QColor textColor() const
Definition: kgrrenderer.cpp:228
QWidget::mapToGlobal
QPoint mapToGlobal(const QPoint &pos) const
FALL1
Definition: kgrscene.h:70
QGraphicsScene::setSceneRect
void setSceneRect(const QRectF &rect)
KGrRenderer::getTileItem
KGameRenderedItem * getTileItem(const char picType, KGameRenderedItem *currentTile)
Definition: kgrrenderer.cpp:139
DIGBRICK1
Definition: kgrscene.h:71
QBrush
QPoint
QFont::setWeight
void setWeight(int weight)
FIELDHEIGHT
const int FIELDHEIGHT
Definition: kgrglobals.h:49
QGraphicsSimpleTextItem::text
QString text() const
KGrScene::animate
void animate(bool missed)
Definition: kgrscene.cpp:488
KGrRenderer::borderColor
QColor borderColor() const
Definition: kgrrenderer.cpp:222
QGraphicsScene::height
qreal height() const
KGrScene::setTitle
void setTitle(const QString &newTitle)
Set the text for the title of the current level.
Definition: kgrscene.cpp:227
QRadialGradient::setFocalPoint
void setFocalPoint(const QPointF &focalPoint)
KGrScene::fadeFinished
void fadeFinished()
QPoint::x
int x() const
QPoint::y
int y() const
KGrScene::gotGold
void gotGold(const int spriteId, const int i, const int j, const bool spriteHasGold, const bool lost=false)
Definition: kgrscene.cpp:551
QGraphicsRectItem::setRect
void setRect(const QRectF &rectangle)
QGraphicsSimpleTextItem::boundingRect
virtual QRectF boundingRect() const
QTimeLine::setCurveShape
void setCurveShape(CurveShape shape)
QPointF
QGraphicsSimpleTextItem
QWidget::size
size
KGrScene::deleteAllSprites
void deleteAllSprites()
Definition: kgrscene.cpp:589
kgrsprite.h
QFont::setPixelSize
void setPixelSize(int pixelSize)
Direction
Direction
Definition: kgrglobals.h:174
LEFT
Definition: kgrglobals.h:174
QString::number
QString number(int n, int base)
QList::count
int count(const T &value) const
QPointF::x
qreal x() const
QPointF::y
qreal y() const
QList::append
void append(const T &value)
NUGGET
const char NUGGET
Definition: kgrglobals.h:37
KGrScene::setPauseResumeText
void setPauseResumeText(const QString &msg)
Definition: kgrscene.cpp:309
animationStartFrames
const StartFrame animationStartFrames[nAnimationTypes]
Definition: kgrscene.cpp:31
KGrScene::changeTheme
void changeTheme()
Redraw the scene whenever the current theme has changed.
Definition: kgrscene.cpp:215
QCursor::setPos
void setPos(int x, int y)
KGrScene::~KGrScene
~KGrScene()
Definition: kgrscene.cpp:103
QGraphicsItem::setPos
void setPos(const QPointF &pos)
FIELDWIDTH
const int FIELDWIDTH
Definition: kgrglobals.h:48
CLOSE_BRICK
Definition: kgrglobals.h:208
KGrScene::setHasHintText
void setHasHintText(const QString &msg)
Definition: kgrscene.cpp:303
StartFrame
StartFrame
Definition: kgrscene.h:61
QGraphicsSimpleTextItem::setFont
void setFont(const QFont &font)
KGrScene::changeSize
void changeSize()
Redraw the scene whenever the view widget is resized.
Definition: kgrscene.cpp:221
FALL_R
Definition: kgrglobals.h:207
KGrScene::goToBlack
void goToBlack()
Definition: kgrscene.cpp:315
KGrSprite::setCoordinateSystem
void setCoordinateSystem(int topLeftX, int topLeftY, int tileSize)
Definition: kgrsprite.cpp:120
QString
QList< int >
QColor
LADDER
const char LADDER
Definition: kgrglobals.h:36
QWidget::isActiveWindow
isActiveWindow
KGrScene::showScore
void showScore(long score)
Definition: kgrscene.cpp:296
QRadialGradient::setRadius
void setRadius(qreal radius)
KGrRenderer
Definition: kgrrenderer.h:61
RIGHTWALK1
Definition: kgrscene.h:61
QSize
QRadialGradient::setCenter
void setCenter(const QPointF &center)
ENEMY
const char ENEMY
Definition: kgrglobals.h:29
BRICK
const char BRICK
Definition: kgrglobals.h:33
kgrscene.h
KGrSprite::move
void move(double x, double y, int frame)
Definition: kgrsprite.cpp:53
QVector::at
const T & at(int i) const
kgrview.h
UP
Definition: kgrglobals.h:174
QRectF::width
qreal width() const
KGrScene::deleteSprite
void deleteSprite(const int id)
Definition: kgrscene.cpp:575
QCursor::pos
QPoint pos()
QGraphicsScene::setItemIndexMethod
void setItemIndexMethod(ItemIndexMethod method)
LEFTCLIMB1
Definition: kgrscene.h:67
QPen::setWidth
void setWidth(int width)
QAbstractGraphicsShapeItem::setPen
void setPen(const QPen &pen)
RIGHTCLIMB1
Definition: kgrscene.h:65
QRectF
nAnimationTypes
Definition: kgrglobals.h:208
QWidget::mapFromGlobal
QPoint mapFromGlobal(const QPoint &pos) const
KGrView
Definition: kgrview.h:27
KGrSprite
Definition: kgrsprite.h:29
FALL2
Definition: kgrscene.h:70
RIGHT
Definition: kgrglobals.h:174
QSize::height
int height() const
KGameRenderedItem
KGrScene::setMousePos
void setMousePos(const int i, const int j)
Definition: kgrscene.cpp:613
QTimeLine
KGrScene::showLives
void showLives(long lives)
Definition: kgrscene.cpp:289
QGraphicsItem::setVisible
void setVisible(bool visible)
QPen
QRectF::height
qreal height() const
QList::lastIndexOf
int lastIndexOf(const T &value, int from) const
KGrScene::setLevel
void setLevel(unsigned int level)
Set the current level number.
Definition: kgrscene.cpp:346
QAbstractGraphicsShapeItem::setBrush
void setBrush(const QBrush &brush)
KGrSprite::setZ
void setZ(qreal z)
Definition: kgrsprite.h:39
QTimeLine::setUpdateInterval
void setUpdateInterval(int interval)
QGraphicsScene::addItem
void addItem(QGraphicsItem *item)
KGrScene::preRenderSprites
void preRenderSprites()
Just as the game starts, ensure that all frames of the "hero" and "enemy" sprites have been rendered...
Definition: kgrscene.cpp:595
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KGrSprite::animate
void animate(bool missed)
Definition: kgrsprite.cpp:91
KGrRenderer::getBorderItem
KGameRenderedItem * getBorderItem(QString spriteKey, KGameRenderedItem *currentItem)
Definition: kgrrenderer.cpp:195
CLIMB1
Definition: kgrscene.h:69
QCursor
QGraphicsItem::setZValue
void setZValue(qreal z)
STAND
Definition: kgrglobals.h:174
KGrScene::startAnimation
void startAnimation(const int id, const bool repeating, const int i, const int j, const int time, const Direction dirn, const AnimationType type)
Requests the view to display an animation of a runner or dug brick at a particular cell...
Definition: kgrscene.cpp:497
QTimeLine::start
void start()
AnimationType
AnimationType
Definition: kgrglobals.h:203
KGrScene::makeSprite
int makeSprite(const char type, int i, int j)
Definition: kgrscene.cpp:442
DOWN
Definition: kgrglobals.h:174
KGrScene::showHiddenLadders
void showHiddenLadders(const QList< int > &ladders, const int width)
Definition: kgrscene.cpp:566
QGraphicsSimpleTextItem::setText
void setText(const QString &text)
FREE
const char FREE
Definition: kgrglobals.h:28
QTimeLine::setDirection
void setDirection(Direction direction)
KGrRenderer::getSpriteItem
KGrSprite * getSpriteItem(const char picType, const int tickTime)
Definition: kgrrenderer.cpp:162
KGrRenderer::getBackground
KGameRenderedItem * getBackground(const int level, KGameRenderedItem *currentBackground)
Definition: kgrrenderer.cpp:179
KGrSprite::changeCoordinateSystem
void changeCoordinateSystem(int topLeftX, int topLeftY, int tileSize)
Definition: kgrsprite.cpp:130
KGrScene::paintCell
void paintCell(const int i, const int j, const char type)
Requests the view to display a particular type of tile at a particular cell, or make it empty and sho...
Definition: kgrscene.cpp:430
KGrRenderer::hasBorder
bool hasBorder() const
Definition: kgrrenderer.cpp:212
KGrScene::KGrScene
KGrScene(KGrView *view)
Definition: kgrscene.cpp:37
QGraphicsScene::width
qreal width() const
QGraphicsRectItem::rect
QRectF rect() const
QFont::setStretch
void setStretch(int factor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgoldrunner

Skip menu "kgoldrunner"
  • Main Page
  • 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