summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -65,4 +65,4 @@ SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
- welcomescreen();
- gamestopped = true;
+ QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
+ gamestopped = true;
waitover = true;
@@ -86,3 +86,3 @@ void SnakeGame::welcomescreen()
title->setColor(yellow);
- title->setFont( QFont("times", 18, QFont::Bold) );
+ title->setFont( QFont("times", 18, QFont::Bold) );
int w = title->boundingRect().width();
@@ -90,6 +90,6 @@ void SnakeGame::welcomescreen()
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"
@@ -104,5 +104,5 @@ void SnakeGame::welcomescreen()
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();
@@ -111,3 +111,3 @@ void SnakeGame::welcomescreen()
void SnakeGame::newGame()
-{
+{
clear();
@@ -126,8 +126,5 @@ void SnakeGame::newGame()
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();
@@ -163,3 +160,3 @@ void SnakeGame::levelUp()
void SnakeGame::createTargets()
-{
+{
for (int i = 0; i < targetamount; i++)
@@ -176,3 +173,3 @@ void SnakeGame::clear()
delete *it;
- }
+ }
}
@@ -184,4 +181,4 @@ void SnakeGame::gameOver()
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);
@@ -194,3 +191,3 @@ void SnakeGame::gameOver()
waitover = false;
- pauseTimer->start(2500);
+ pauseTimer->start(1500);
}
@@ -202,3 +199,3 @@ void SnakeGame::wait()
QCanvasText* cont = new QCanvasText(tr("Press Any Key to Begin a New Game."),
- &canvas);
+ &canvas);
cont->setZ(100);
@@ -211,10 +208,10 @@ void SnakeGame::wait()
void SnakeGame::keyPressEvent(QKeyEvent* event)
-{
+{
if (gamestopped) {
- if (waitover)
+ if (waitover)
newGame();
- else
+ else
return;
}
- else {
+ else {
int newkey = event->key();