summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-14 08:33:57 (UTC)
committer zecke <zecke>2003-05-14 08:33:57 (UTC)
commit79e34e9dc4870885c58f80c29a723d0227f7b788 (patch) (side-by-side diff)
tree1e91a0e6d698c782ef975e023288d4b9817e82c6
parent81a58bae78d693b67679d94d2f7fcdb300e12d4f (diff)
downloadopie-79e34e9dc4870885c58f80c29a723d0227f7b788.zip
opie-79e34e9dc4870885c58f80c29a723d0227f7b788.tar.gz
opie-79e34e9dc4870885c58f80c29a723d0227f7b788.tar.bz2
patch by Scott Bronson.
Add a little game description in the about messagebox
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/bounce/kbounce.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp
index f703f74..5d8aba3 100644
--- a/noncore/games/bounce/kbounce.cpp
+++ b/noncore/games/bounce/kbounce.cpp
@@ -20,193 +20,202 @@
#include <qtimer.h>
#include <qlcdnumber.h>
#include <qmessagebox.h>
#include <qmainwindow.h>
#include <qpe/qpeapplication.h>
#include "kbounce.h"
#include "game.h"
#include <qlabel.h>
KJezzball::KJezzball() : QMainWindow(0), m_gameWidget( 0 )
{
setCaption(tr("Bounce"));
// setup variables
m_game.level = 1;
m_game.score = 0;
m_state = Idle;
menu = menuBar();
game = new QPopupMenu;
game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P );
game->insertSeparator();
game->insertItem(tr("&About"), this, SLOT(about()));
menu->insertItem( tr("&Game"), game );
// create widgets
m_view = new QWidget( this, "m_view" );
setCentralWidget( m_view );
m_layout = new QGridLayout( m_view );
m_layout->setSpacing( 0 );
m_layout->setMargin( 0 );
ScoreLabel = new QLabel( m_view, "ScoreLabel" );
ScoreLabel->setText( tr( "Score: 00" ) );
ScoreLabel->setAlignment( int( QLabel::AlignCenter ) );
m_layout->addWidget( ScoreLabel, 1, 0 );
LivesLabel = new QLabel( m_view, "LivesLabel" );
LivesLabel->setText( tr( "Lives: 0%" ) );
LivesLabel->setAlignment( int( QLabel::AlignCenter ) );
m_layout->addWidget( LivesLabel, 1, 2 );
FilledLabel = new QLabel( m_view, "FilledLabel" );
FilledLabel->setText( tr( "Filled: 00%" ) );
FilledLabel->setAlignment( int( QLabel::AlignCenter ) );
m_layout->addWidget( FilledLabel, 1, 1 );
TimeLabel = new QLabel( m_view, "TimeLabel" );
TimeLabel->setText( tr( "Time: 00" ) );
TimeLabel->setAlignment( int( QLabel::AlignCenter ) );
m_layout->addWidget( TimeLabel, 1, 3 );
// create timers
m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" );
connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) );
m_gameOverTimer = new QTimer( this, "m_gameOverTimer" );
connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) );
m_timer = new QTimer( this, "m_timer" );
connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) );
// create demo game
createLevel( 1 );
}
void KJezzball::newGame()
{
// Check for running game
closeGame();
if ( m_state==Idle )
{
// update displays
m_game.level = 1;
m_game.score = 0;
setCaption(tr("Bounce Level %1").arg(m_game.level));
ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
// start new game
m_state = Running;
createLevel( m_game.level );
startLevel();
}
}
void KJezzball::about()
{
- QMessageBox::information( this, "About", "Written by: Stefan Schimanski\nPorted by: Martin Imobersteg\n\nThis program is distributed under\nthe terms of the GPL v2." );
+ QMessageBox::information( this, "About",
+ "Written by: Stefan Schimanski\n"
+ "Ported by: Martin Imobersteg\n"
+ "\n"
+ "Click to form walls.\n"
+ "Hit space to switch wall direction.\n"
+ "Try to reduce total space by 75%.\n"
+ "\n"
+ "This program is distributed under\n"
+ "the terms of the GPL v2." );
}
void KJezzball::closeGame()
{
if ( m_state!=Idle )
{
stopLevel();
m_state = Idle;
}
}
void KJezzball::pauseGame()
{
switch ( m_state )
{
case Running:
m_state = Paused;
m_gameWidget->display( tr("Game paused.\nPress P to continue!") );
stopLevel();
break;
case Paused:
case Suspend:
m_state = Running;
m_gameWidget->display( QString::null );
startLevel();
break;
case Idle:
break;
}
}
void KJezzball::gameOver()
{
stopLevel();
m_gameOverTimer->start( 100, TRUE );
}
void KJezzball::gameOverNow()
{
m_state = Idle;
QString score;
score.setNum( m_game.score );
QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) );
}
void KJezzball::focusOutEvent( QFocusEvent *ev )
{
if ( m_state==Running )
{
stopLevel();
m_state = Suspend;
}
QMainWindow::focusOutEvent( ev );
}
void KJezzball::focusInEvent ( QFocusEvent *ev )
{
if ( m_state==Suspend )
{
startLevel();
m_state = Running;
}
QMainWindow::focusInEvent( ev );
}
void KJezzball::second()
{
m_level.time--;
TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
if ( m_level.time<=0 )
{
gameOver();
}
}
void KJezzball::died()
{
m_level.lifes--;
LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
if ( m_level.lifes==0 ) gameOver();
}
void KJezzball::newPercent( int percent )
{
FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) );
if ( percent>=75 )
{
m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5);
nextLevel();
}