[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-games-devel
Subject: Re: [Kde-games-devel] Kapman
From: "Aaron J. Seigo" <aseigo () kde ! org>
Date: 2008-03-21 19:29:56
Message-ID: 200803211329.56782.aseigo () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On Friday 21 March 2008, Ian Wadham wrote:
> the X-server, for example. Also try exporting QT_FLUSH_PAINT
> and observing how much of your view is being re-painted.
the only unnecessary repaints i see is that on every pellet eaten not one is
the score repainted, but the number of lives and the level. really, only the
number next to the Score: label needs to be. so it's not a large area, but
those repaints are completely unecessary.
the attached patch fixes that, and also changes the ItemIndexMethod to NoIndex
in the scene which is more appropriate for non-static scenes.
yes, i am feeling slightly bored and unmotivated today.. it is easter holiday
after all ;)
> using QGraphicsView or KGameCanvas or QPainter direct?
QGraphicsView
--
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
KDE core developer sponsored by Trolltech
["small_kapman_improvements.diff" (text/x-diff)]
Index: game.cpp
===================================================================
--- game.cpp (revision 786478)
+++ game.cpp (working copy)
@@ -240,7 +240,7 @@
// Cheat code to get one more life
if (p_event->modifiers() == Qt::AltModifier | Qt::ControlModifier | \
Qt::ShiftModifier) { m_lives++;
- emit(updatingInfos());
+ emit(updatingInfos(LivesInfo));
}
default:
break;
@@ -303,7 +303,7 @@
void Game::kapmanDeath() {
m_lives --;
- emit(updatingInfos());
+ emit(updatingInfos(LivesInfo));
emit(sDisableDisplayBonus());
@@ -358,7 +358,7 @@
}
// Update view
- emit(updatingInfos());
+ emit(updatingInfos(ScoreInfo));
}
void Game::nextLevel() {
@@ -369,7 +369,7 @@
// Increase the ghosts speed
Ghost::increaseGhostsSpeed(0.05);
// To update the score, level and lives labels
- emit(updatingInfos());
+ emit(updatingInfos(AllInfo));
// To reinit the maze items
emit(leveled());
m_maze->resetNbElem();
Index: gamescene.h
===================================================================
--- gamescene.h (revision 786478)
+++ gamescene.h (working copy)
@@ -114,7 +114,7 @@
/**
* Upadate the score and lives labels
*/
- void updateInfos();
+ void updateInfos(Game::InformationTypes);
};
#endif
Index: game.h
===================================================================
--- game.h (revision 786478)
+++ game.h (working copy)
@@ -85,6 +85,13 @@
public:
+ enum Information { NoInfo = 0,
+ ScoreInfo = 1,
+ LivesInfo = 2,
+ LevelInfo = 4,
+ AllInfo = ScoreInfo | LivesInfo | LevelInfo };
+ Q_DECLARE_FLAGS(InformationTypes, Information);
+
/**
* Creates a new Game instance
*/
@@ -264,7 +271,7 @@
/**
* Signals to the scene to update the score and lives' labels
*/
- void updatingInfos();
+ void updatingInfos(Game::InformationTypes types);
/**
* Signal to the kapmanmainwindow to start a newgame when there isn't more lives \
or when a level is finished
Index: gamescene.cpp
===================================================================
--- gamescene.cpp (revision 786478)
+++ gamescene.cpp (working copy)
@@ -22,7 +22,8 @@
#include "bonus.h"
GameScene::GameScene(Game * p_game) : m_game(p_game) {
-
+ setItemIndexMethod(NoIndex);
+
// Create the 'PAUSE' label
m_pauseLabel = new QGraphicsTextItem( ki18n("PAUSED").toString() );
m_pauseLabel->setFont( QFont("Helvetica", 35, QFont::Bold, false) );
@@ -112,7 +113,7 @@
m_levelLabel->setZValue(3);
// Init the score, lives and level labels
- updateInfos();
+ updateInfos(Game::AllInfo);
// Connect managePause signal to the scene
connect(p_game, SIGNAL(managePause(bool)), this, SLOT(managePause(bool)));
@@ -127,7 +128,8 @@
// Connect disableDisplayBonus signal to the scene
connect(p_game, SIGNAL(sDisableDisplayBonus()), this, SLOT(killBonus()));
// Connect the kapman to the "updateInfos()" slot
- connect(p_game, SIGNAL(updatingInfos()), this, SLOT(updateInfos()));
+ connect(p_game, SIGNAL(updatingInfos(Game::InformationTypes)), this,
+ SLOT(updateInfos(Game::InformationTypes)));
// Reinit the items on level completed
connect(p_game, SIGNAL(leveled()), this, SLOT(initItems()));
@@ -155,18 +157,24 @@
delete[] m_elementItemList;
}
-void GameScene::updateInfos() {
- QString lives("Lives : ");
- lives += QString::number((int)m_game->getLives());
- m_livesLabel->setPlainText(lives);
+void GameScene::updateInfos(Game::InformationTypes info) {
+ if (info & Game::LivesInfo) {
+ QString lives("Lives : ");
+ lives += QString::number((int)m_game->getLives());
+ m_livesLabel->setPlainText(lives);
+ }
- QString score("Score : ");
- score += QString::number((double)m_game->getScore());
- m_scoreLabel->setPlainText(score);
+ if (info & Game::ScoreInfo) {
+ QString score("Score : ");
+ score += QString::number((double)m_game->getScore());
+ m_scoreLabel->setPlainText(score);
+ }
- QString level("Level : ");
- level += QString::number((int)m_game->getLevel());
- m_levelLabel->setPlainText(level);
+ if (info & Game::LevelInfo) {
+ QString level("Level : ");
+ level += QString::number((int)m_game->getLevel());
+ m_levelLabel->setPlainText(level);
+ }
}
["signature.asc" (application/pgp-signature)]
_______________________________________________
kde-games-devel mailing list
kde-games-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-games-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic