import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
public class SnakeApplication
{
public static JLabel Titel = null;
public static JButton FirstButton = null,
SecondButton = null,
ThirdButton = null,
BackButton = null;
public static JFrame MainFrame = new JFrame( "Snake Ultimate" ),
GameFrame = new JFrame( "Snake Ultimate INGAME" );
public static String Difficulty = "Medium";
public static Graphics Graphics = null;
public static boolean Vsync = true;
public static Dimension Resolution = new Dimension( 1280, 900 );
public static BufferStrategy BufStrat = null;
public static void main( String[] args )
{
new SnakeApplication();
}
public SnakeApplication()
{
InitializeFrames();
if( JOptionPane.showConfirmDialog(null, "Snake mit Menü Starten?", "Snake Ultimate", JOptionPane.YES_NO_OPTION) == 0 )
InitializeInterface();
else
new SnakeGame();
}
private void InitializeFrames()
{
MainFrame.setSize ( new Dimension( 640, 480 ) );
MainFrame.setDefaultCloseOperation ( 0 );
GameFrame.setDefaultCloseOperation ( 0 );
MainFrame.setUndecorated ( true );
GameFrame.setUndecorated ( true );
MainFrame.setResizable ( false );
GameFrame.setResizable ( false );
MainFrame.getContentPane().setLayout ( null );
MainFrame.getContentPane().setBackground( Color.BLACK );
MainFrame.setLocation ( new Point( GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint().x - 320,
GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint().y - 240 ) );
GameFrame.setCursor ( Toolkit.getDefaultToolkit().createCustomCursor( new BufferedImage(
1, 1, BufferedImage.TYPE_4BYTE_ABGR ), new Point( 0,0 ), "NOCURSOR" ) );
MainFrame.setVisible ( true );
}
public static void InitializeFrame2()
{
GameFrame.setSize ( Resolution );
GameFrame.setLocation ( new Point( GraphicsEnvironment.getLocalGraphicsEnvironment()
.getCenterPoint().x - ( GameFrame.getSize().width / 2 ), GraphicsEnvironment
.getLocalGraphicsEnvironment().getCenterPoint().y - ( GameFrame.getSize().height / 2 ) ) );
GameFrame.addKeyListener ( new Listener() );
GameFrame.addWindowFocusListener ( new Listener() );
GameFrame.requestFocus();
GameFrame.setVisible ( true );
GameFrame.createBufferStrategy ( 2 );
BufStrat = GameFrame.getBufferStrategy();
}
private void InitializeInterface()
{
Container Panel = MainFrame.getContentPane();
FirstButton = new JButton();
SecondButton = new JButton();
ThirdButton = new JButton();
BackButton = new JButton();
Titel = new JLabel();
FirstButton.setBounds ( new Rectangle( 70, 125, 500, 60 ) );
SecondButton.setBounds ( new Rectangle( 70, 225, 500, 60 ) );
ThirdButton.setBounds ( new Rectangle( 70, 325, 500, 60 ) );
BackButton.setBounds ( new Rectangle( 450, 425, 150, 35 ) );
Titel.setBounds ( new Rectangle( 0, 15, 640, 55 ) );
FirstButton.setVisible ( false );
SecondButton.setVisible ( false );
ThirdButton.setVisible ( false );
BackButton.setVisible ( false );
FirstButton.setBackground ( Color.BLACK );
SecondButton.setBackground ( Color.BLACK );
ThirdButton.setBackground ( Color.BLACK );
BackButton.setBackground ( Color.BLACK );
FirstButton.setForeground ( Color.RED );
SecondButton.setForeground ( Color.RED );
ThirdButton.setForeground ( Color.RED );
BackButton.setForeground ( Color.RED );
Titel.setForeground ( Color.RED );
FirstButton.setFont ( new Font( "Monospaced", Font.ITALIC, 32 ) );
SecondButton.setFont ( new Font( "Monospaced", Font.ITALIC, 32 ) );
ThirdButton.setFont ( new Font( "Monospaced", Font.ITALIC, 32 ) );
BackButton.setFont ( new Font( "Monospaced", Font.ITALIC, 22 ) );
Titel.setFont ( new Font( "Geneva", Font.BOLD, 48 ) );
Titel.setHorizontalAlignment ( SwingConstants.CENTER );
Titel.setHorizontalTextPosition ( SwingConstants.CENTER );
FirstButton.addActionListener ( new Listener() );
SecondButton.addActionListener ( new Listener() );
ThirdButton.addActionListener ( new Listener() );
BackButton.addActionListener ( new Listener() );
Panel.add ( Titel, null );
Panel.add ( FirstButton, null );
Panel.add ( SecondButton, null );
Panel.add ( ThirdButton, null );
Panel.add ( BackButton, null );
new menu ( "MainMenu" );
}
}