summaryrefslogtreecommitdiff
path: root/noncore
authorharlekin <harlekin>2002-05-15 17:33:19 (UTC)
committer harlekin <harlekin>2002-05-15 17:33:19 (UTC)
commit968718335dd546fcb0f7cd27094d151a247f6c48 (patch) (side-by-side diff)
tree2cd22f9a78477f09bf58eb341dd1eb96eabc6cbd /noncore
parenta1f53542132be75295e52b17661204860bc486d4 (diff)
downloadopie-968718335dd546fcb0f7cd27094d151a247f6c48.zip
opie-968718335dd546fcb0f7cd27094d151a247f6c48.tar.gz
opie-968718335dd546fcb0f7cd27094d151a247f6c48.tar.bz2
image relocation
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/snake/interface.cpp43
1 files changed, 20 insertions, 23 deletions
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp
index c9b4931..c824543 100644
--- a/noncore/games/snake/interface.cpp
+++ b/noncore/games/snake/interface.cpp
@@ -63,8 +63,8 @@ SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
setCentralWidget(cv);
- welcomescreen();
- gamestopped = true;
+ QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
+ gamestopped = true;
waitover = true;
}
@@ -84,14 +84,14 @@ void SnakeGame::welcomescreen()
{
QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas);
title->setColor(yellow);
- title->setFont( QFont("times", 18, QFont::Bold) );
+ title->setFont( QFont("times", 18, QFont::Bold) );
int w = title->boundingRect().width();
title->move(canvas.width()/2 -w/2, canvas.height()/2-110);
title->show();
- QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("title"));
+ QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
- titlepic->show();
+ titlepic->show();
QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
"snake to eat the mouse. You must not\n"
"crash into the walls, edges or its tail."),
@@ -102,14 +102,14 @@ void SnakeGame::welcomescreen()
instr->show();
QCanvasText* cont = new QCanvasText(tr("Press Any Key To Start"), &canvas);
w = cont->boundingRect().width();
- cont->move(canvas.width()/2-w/2, canvas.height()/2+80);
+ cont->move(canvas.width()/2-w/2, canvas.height()-20);
cont->setColor(yellow);
- cont->show();
+ cont->show();
}
void SnakeGame::newGame()
-{
+{
clear();
snake = new Snake(&canvas);
connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) );
@@ -124,12 +124,9 @@ void SnakeGame::newGame()
showScore(0);
gamestopped = false;
waitover = true;
- int x = canvas.width()/2 - 70;
- x = x - x % 16;
int y = canvas.height()-50;
- y = y - y % 16;
- (void)new Obstacle(&canvas, x, 32);
- (void)new Obstacle(&canvas, x, y);
+ (void)new Obstacle(&canvas, 32);
+ (void)new Obstacle(&canvas, y);
createTargets();
}
@@ -161,7 +158,7 @@ void SnakeGame::levelUp()
}
void SnakeGame::createTargets()
-{
+{
for (int i = 0; i < targetamount; i++)
(void)new Target(&canvas);
notargets = targetamount;
@@ -174,7 +171,7 @@ void SnakeGame::clear()
QCanvasItemList l = canvas.allItems();
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
delete *it;
- }
+ }
}
void SnakeGame::gameOver()
@@ -182,8 +179,8 @@ void SnakeGame::gameOver()
int score = snake->getScore();
QString scoreoutput="";
scoreoutput.setNum(score);
- QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
-
+ QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
+
gameover->setZ(100);
gameover->setColor(yellow);
gameover->setFont( QFont("times", 18, QFont::Bold) );
@@ -192,7 +189,7 @@ void SnakeGame::gameOver()
gameover->show();
gamestopped = true;
waitover = false;
- pauseTimer->start(2500);
+ pauseTimer->start(1500);
}
void SnakeGame::wait()
@@ -200,7 +197,7 @@ void SnakeGame::wait()
waitover = true;
pauseTimer->stop();
QCanvasText* cont = new QCanvasText(tr("Press Any Key to Begin a New Game."),
- &canvas);
+ &canvas);
cont->setZ(100);
cont->setColor(white);
int w = cont->boundingRect().width();
@@ -209,14 +206,14 @@ void SnakeGame::wait()
}
void SnakeGame::keyPressEvent(QKeyEvent* event)
-{
+{
if (gamestopped) {
- if (waitover)
+ if (waitover)
newGame();
- else
+ else
return;
}
- else {
+ else {
int newkey = event->key();
snake->go(newkey);
}