summaryrefslogtreecommitdiff
Unidiff
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) :
65 65
66 welcomescreen(); 66 QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
67 gamestopped = true; 67 gamestopped = true;
68 waitover = true; 68 waitover = true;
@@ -86,3 +86,3 @@ void SnakeGame::welcomescreen()
86 title->setColor(yellow); 86 title->setColor(yellow);
87 title->setFont( QFont("times", 18, QFont::Bold) ); 87 title->setFont( QFont("times", 18, QFont::Bold) );
88 int w = title->boundingRect().width(); 88 int w = title->boundingRect().width();
@@ -90,6 +90,6 @@ void SnakeGame::welcomescreen()
90 title->show(); 90 title->show();
91 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("title")); 91 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
92 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); 92 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
93 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); 93 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
94 titlepic->show(); 94 titlepic->show();
95 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" 95 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
@@ -104,5 +104,5 @@ void SnakeGame::welcomescreen()
104 w = cont->boundingRect().width(); 104 w = cont->boundingRect().width();
105 cont->move(canvas.width()/2-w/2, canvas.height()/2+80); 105 cont->move(canvas.width()/2-w/2, canvas.height()-20);
106 cont->setColor(yellow); 106 cont->setColor(yellow);
107 cont->show(); 107 cont->show();
108 108
@@ -111,3 +111,3 @@ void SnakeGame::welcomescreen()
111void SnakeGame::newGame() 111void SnakeGame::newGame()
112{ 112{
113 clear(); 113 clear();
@@ -126,8 +126,5 @@ void SnakeGame::newGame()
126 waitover = true; 126 waitover = true;
127 int x = canvas.width()/2 - 70;
128 x = x - x % 16;
129 int y = canvas.height()-50; 127 int y = canvas.height()-50;
130 y = y - y % 16; 128 (void)new Obstacle(&canvas, 32);
131 (void)new Obstacle(&canvas, x, 32); 129 (void)new Obstacle(&canvas, y);
132 (void)new Obstacle(&canvas, x, y);
133 createTargets(); 130 createTargets();
@@ -163,3 +160,3 @@ void SnakeGame::levelUp()
163void SnakeGame::createTargets() 160void SnakeGame::createTargets()
164{ 161{
165 for (int i = 0; i < targetamount; i++) 162 for (int i = 0; i < targetamount; i++)
@@ -176,3 +173,3 @@ void SnakeGame::clear()
176 delete *it; 173 delete *it;
177 } 174 }
178} 175}
@@ -184,4 +181,4 @@ void SnakeGame::gameOver()
184 scoreoutput.setNum(score); 181 scoreoutput.setNum(score);
185 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas); 182 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
186 183
187 gameover->setZ(100); 184 gameover->setZ(100);
@@ -194,3 +191,3 @@ void SnakeGame::gameOver()
194 waitover = false; 191 waitover = false;
195 pauseTimer->start(2500); 192 pauseTimer->start(1500);
196} 193}
@@ -202,3 +199,3 @@ void SnakeGame::wait()
202 QCanvasText* cont = new QCanvasText(tr("Press Any Key to Begin a New Game."), 199 QCanvasText* cont = new QCanvasText(tr("Press Any Key to Begin a New Game."),
203 &canvas); 200 &canvas);
204 cont->setZ(100); 201 cont->setZ(100);
@@ -211,10 +208,10 @@ void SnakeGame::wait()
211void SnakeGame::keyPressEvent(QKeyEvent* event) 208void SnakeGame::keyPressEvent(QKeyEvent* event)
212{ 209{
213 if (gamestopped) { 210 if (gamestopped) {
214 if (waitover) 211 if (waitover)
215 newGame(); 212 newGame();
216 else 213 else
217 return; 214 return;
218 } 215 }
219 else { 216 else {
220 int newkey = event->key(); 217 int newkey = event->key();