root/Bump_n_Jump/src/Game.java
| 79 | 83 | ||
|---|---|---|---|
79 | newLevelSnd = new SoundPlayback("music/NewLevel.aif"); | 79 | newLevelSnd = new SoundPlayback("music/NewLevel.aif"); |
80 | levelMusicSnd = new SoundPlayback("music/Level_music.aif", true); | 80 | levelMusicSnd = new SoundPlayback("music/Level_music.aif", true); |
81 | gameplaySnd = new SoundPlayback("music/gameplaymusic.aif"); | 81 | gameplaySnd = new SoundPlayback("music/gameplaymusic.aif"); |
82 | openingSnd = new SoundPlayback("music/openingmusic.aif", true); | 82 | openingSnd = new SoundPlayback("music/openingmusic.aif"); |
83 | 83 | ||
84 | 84 | ||
85 | livesLeft = 6; | 85 | livesLeft = 1; |
86 | levelNum = 0; | 86 | levelNum = 0; |
87 | levelCreator = new LevelCreator(); | 87 | levelCreator = new LevelCreator(); |
88 | nextLevel(); | 88 | nextLevel(); |
... | ... | ||
105 | openingSnd.start(); | 105 | openingSnd.start(); |
106 | } | 106 | } |
107 | 107 | ||
108 | private void startEverythingOver() { | ||
109 | livesLeft = 1; | ||
110 | levelNum = 0; | ||
111 | levelCreator = new LevelCreator(); | ||
112 | nextLevel(); | ||
113 | |||
114 | //create new thread | ||
115 | mainLoop = new Thread(this); | ||
116 | gameStarted = beatTheGame = gameOver = false; | ||
117 | menuScreen = MENU; | ||
118 | gameplaySnd.stop(); | ||
119 | openingSnd.start(); | ||
120 | menuScreen(); | ||
121 | } | ||
122 | |||
108 | /** | 123 | /** |
109 | * shows the menu screen with options to show instructions, play the game, and quit. | 124 | * shows the menu screen with options to show instructions, play the game, and quit. |
110 | */ | 125 | */ |
... | ... | ||
137 | if (bs.isDead()) { | 152 | if (bs.isDead()) { |
138 | deadSnd.stop(); | 153 | deadSnd.stop(); |
139 | deadSnd.start(); | 154 | deadSnd.start(); |
140 | //deadSnd.stop(); | ||
141 | 155 | ||
142 | if (livesLeft == 0) { | 156 | if (livesLeft == 0) { |
143 | // Stop level music at end of game | 157 | // Stop level music at end of game |
144 | levelMusicSnd.stop(); | 158 | gameplaySnd.stop(); |
145 | |||
146 | gameStarted = false; | 159 | gameStarted = false; |
147 | gameOver = true; | 160 | gameOver = true; |
161 | bs.getCircle().setFrame(-10, -10, 0,0); | ||
162 | bs.setIsDead(false); | ||
148 | try { | 163 | try { |
149 | Thread.sleep(1000L); | 164 | Thread.sleep(1000L); |
150 | } catch (InterruptedException e) {} | 165 | } catch (InterruptedException e) {} |
... | ... | ||
326 | g.drawImage(arrow, arrowX, arrowY, null); | 341 | g.drawImage(arrow, arrowX, arrowY, null); |
327 | } | 342 | } |
328 | else if (beatTheGame) { | 343 | else if (beatTheGame) { |
344 | mainLoop = null; | ||
329 | g.drawImage(menuImageBeat, 0, 0, null); | 345 | g.drawImage(menuImageBeat, 0, 0, null); |
330 | } | 346 | } |
331 | else if (gameOver) { | 347 | else if (gameOver) { |
348 | mainLoop = null; | ||
332 | g.drawImage(menuImageGameOver, 0, 0, null); | 349 | g.drawImage(menuImageGameOver, 0, 0, null); |
350 | deadSnd.stop(); | ||
333 | } | 351 | } |
334 | 352 | ||
335 | } | 353 | } |
... | ... | ||
503 | arrowY = ARROWY1; | 521 | arrowY = ARROWY1; |
504 | repaint(); | 522 | repaint(); |
505 | } | 523 | } |
524 | else if ((gameOver && !gameStarted) || beatTheGame){ | ||
525 | gameOver = false; | ||
526 | gameStarted = false; | ||
527 | startEverythingOver(); | ||
528 | } | ||
506 | } | 529 | } |
507 | else if (e.getKeyCode() == KeyEvent.VK_F12) { | 530 | else if (e.getKeyCode() == KeyEvent.VK_F12) { |
508 | nextLevel(); | 531 | nextLevel(); |
Download diff