name: "Ending" endings { name: "RED" path: "Components/end" } ndex, nofollow'/>
summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java
blob: 746678820b957ad360c4349e58a3d9fef2962627 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.gamestate;

import com.fourisland.fourpuzzle.Audio;
import com.fourisland.fourpuzzle.database.Database;
import com.fourisland.fourpuzzle.Display;
import com.fourisland.fourpuzzle.Game;
import com.fourisland.fourpuzzle.KeyInput;
import com.fourisland.fourpuzzle.SaveFile;
import com.fourisland.fourpuzzle.database.Music;
import com.fourisland.fourpuzzle.database.Transitions;
import com.fourisland.fourpuzzle.util.ObjectLoader;
import java.awt.Graphics2D;

/**
 *
 * @author hatkirby
 */
public class GameOverGameState implements GameState {
    
    public void initalize()
    {
        // Play the Database-specifed Game Over music
        Audio.playMusic(Database.getMusic(Music.GameOver));
    }
    
    public void deinitalize()
    {
        // Stop the music
        Audio.stopMusic();
    }

    public void processInput(KeyInput key)
    {
        if (key.isActionDown())
        {
            /* When the user presses the action key to exit the game over
             * screen, clear the save data and transition back to the title
             * screen.
             * 
             * NOTE: Clearing the save data may not actually be necessary here
             * because TitleScreenGameState clears the save data before starting
             * a new file */
            Game.setSaveFile(new SaveFile());
            
            try {
                Display.transition(Database.getTransition(Transitions.Generic), new TitleScreenGameState(), true);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
            }
        }
    }

    public void doGameCycle()
    {
        // Do nothing
    }

    public void render(Graphics2D g)
    {
        // Display the Game Over picture
        g.drawImage(ObjectLoader.getImage("Picture", "GameOver"), 0, 0, null);
    }

}