summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java
blob: 621ec0df9e7d5374ce3158531adb1cf376ca20f8 (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
70
71
72
73
74
75
76
77
78
79
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.gamestate;

import com.fourisland.fourpuzzle.*;
import com.fourisland.fourpuzzle.gamestate.mapview.MapViewGameState;
import com.fourisland.fourpuzzle.transition.SquareTransition;
import com.fourisland.fourpuzzle.transition.TransitionDirection;
import com.fourisland.fourpuzzle.util.ObjectLoader;
import com.fourisland.fourpuzzle.window.ChoiceWindow;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.util.Arrays;

/**
 *
 * @author hatkirby
 */
public class TitleScreenGameState implements GameState {
    
    ChoiceWindow choices;
    int wx, wy;
    
    public void initalize()
    {
        Audio.playMusic(Database.getMusic("Title"));
        
        choices = new ChoiceWindow(Arrays.asList(Database.getVocab("NewGame"), Database.getVocab("LoadGame"), Database.getVocab("EndGame")));
        
        wx = (Game.WIDTH/2)-(choices.getWidth()/2);
        wy = (Game.HEIGHT/4*3)-(choices.getHeight()/2);
    }
    
    public void deinitalize()
    {
        Audio.stopMusic();
    }

    public void processInput()
    {
        if (Game.getKey().getKeyCode() == KeyEvent.VK_ENTER)
        {
            Game.setSaveFile(new SaveFile());
            
            new Thread(new Runnable() {
                public void run() {
                    try {
                        Display.transition(new SquareTransition(TransitionDirection.Out));
                    } catch (InterruptedException ex) {
                        Thread.currentThread().interrupt();
                    }
                    
                    Game.setGameState(new MapViewGameState("TestMap", 1, 2));
                    
                    try {
                        Display.transition(new SquareTransition(TransitionDirection.In));
                    } catch (InterruptedException ex) {
                        Thread.currentThread().interrupt();
                    }
                }
            }).start();
        }
    }

    public void doGameCycle()
    {
        // Do nothing, yet
    }

    public void render(Graphics2D g)
    {
        g.drawImage(ObjectLoader.getImage("Picture", "Title"), 0, 0, null);
        choices.render(g, wx, wy);
    }

}