public static void main(String args[])
	{
		try
		{
	        int screenWidth = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
	        int screenHeight = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
	          
	        windowWidth = (screenWidth < NBBLOCKX*32 ? screenWidth-10 : NBBLOCKX*32);
	        windowHeight = (screenHeight < NBBLOCKY*32 ? screenHeight-100 : NBBLOCKY*32);
		    BomberMania bomberMania = new BomberMania(windowWidth, windowHeight);
		    canvas = new CanvasGameContainer(bomberMania);
		    canvas.setPreferredSize(new Dimension(windowWidth, windowHeight));
		    canvas.getContainer().setTargetFrameRate(30);
		    canvas.getContainer().setShowFPS(true);
		    canvas.setBounds(0, 25, windowWidth, windowHeight);
		    
		    JPanel total = new JPanel(null);
		    
		    JMenuItem defaultMap = new JMenuItem("Nouvelle partie", new ImageIcon("data/images/menu/page_white.png"));
		    defaultMap.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
		    defaultMap.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    editorMode = false;
                    onGame=true;
                    game.start("data/map/default.bmmap");
                }
            });
		    
		    JMenuItem loadMap = new JMenuItem("Ouvrir une carte...", new ImageIcon("data/images/menu/folder.png"));
		    loadMap.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
		    loadMap.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    int retour = chooser.showOpenDialog(frame);          
                    if(retour == JFileChooser.APPROVE_OPTION)
                    {
                        editorMode = false;
                        onGame = true;
                        game.start(chooser.getSelectedFile().getAbsolutePath());
                    }
                }
            });
		    
		    
		    close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
		    close.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    game.showIntro();
                }
            });
		    
		    JMenuItem exit = new JMenuItem("Quitter", new ImageIcon("data/images/menu/door_out.png"));
		    exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
		    exit.addActionListener(new ActionListener()
		    {
		        @Override
		        public void actionPerformed(ActionEvent e)
		        {
		        	WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
					Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);
		        }
		    });
		    
		    JMenu fichier = new JMenu("Jeu");
		    
		    fichier.add(defaultMap);
		    fichier.add(loadMap);
		    fichier.add(close);
		    fichier.addSeparator();
		    fichier.add(exit);

		    
		    JMenuItem mapEditorNew = new JMenuItem("Nouveau", new ImageIcon("data/images/menu/page_white.png"));
		    mapEditorNew.addActionListener(new ActionListener()
            {
                
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    mapEditorSave.setEnabled(false);
                    currentMapEditorSaveTarget = new String();
                    mapEditorSaveAs.setEnabled(true);
                    editorMode = true;
                    onGame = false;
                    game.start("data/map/empty.bmmap");
                }
            });
		    
		    JMenuItem mapEditorOpen = new JMenuItem("Ouvrir...", new ImageIcon("data/images/menu/folder.png"));
		    mapEditorOpen.addActionListener(new ActionListener()
	        {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    int retour = chooser.showOpenDialog(frame);          
                    if(retour == JFileChooser.APPROVE_OPTION)
                    {
                        editorMode = true;
                        onGame = false;
                        game.start(chooser.getSelectedFile().getAbsolutePath());
                        mapEditorSave.setEnabled(true);
                        mapEditorSaveAs.setEnabled(true);
                        currentMapEditorSaveTarget = chooser.getSelectedFile().getAbsolutePath();
                    }
                }
	        });
		    

		    mapEditorSave.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    map.saveMap(currentMapEditorSaveTarget);
                }
            });
		    mapEditorSave.setEnabled(false);
	    
		    mapEditorSaveAs.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    int retour = chooser.showSaveDialog(frame);          
                    if(retour == JFileChooser.APPROVE_OPTION)
                    {
                        String fileName = chooser.getSelectedFile().getAbsolutePath();
                        String extension = Utils.getExtension(new File(fileName));
                        if(extension == null || !extension.equals(new String("bmmap")))
                            fileName += ".bmmap";
                        
                        map.saveMap(fileName);
                        mapEditorSave.setEnabled(true);
                        currentMapEditorSaveTarget = chooser.getSelectedFile().getAbsolutePath();
                    }
                }
            });
		    
		    
		    mapEditorSaveAs.setEnabled(false);
		    
	        JMenu mapEditor = new JMenu("Éditeur de cartes");
		    mapEditor.add(mapEditorNew);
		    mapEditor.add(mapEditorOpen);
		    mapEditor.add(mapEditorSave);
		    mapEditor.add(mapEditorSaveAs);
	        
		    JMenuItem credits = new JMenuItem("Crédits");
		    credits.addActionListener(new ActionListener()
            {
                
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    JOptionPane.showMessageDialog(frame, "Ce jeu a été développé par des étudiants de deuxième année de DUT informatique :\nGaillard Damien\nGardize Joannick\nTirmarche Étienne\nSinnaeve Alexis\nWetterwald Martin", "Crédits", JOptionPane.INFORMATION_MESSAGE);
                }
            });
		    
	        JMenu help = new JMenu("?");
	        help.add(credits);
		    
		    JMenuBar menuBar = new JMenuBar();
		    menuBar.setPreferredSize(new Dimension(windowWidth, 25));
		    menuBar.add(fichier);
		    menuBar.add(mapEditor);
		    menuBar.add(help);
		    menuBar.setBounds(0, 0, (int)menuBar.getPreferredSize().getWidth(), (int)menuBar.getPreferredSize().getHeight());
		    total.add(menuBar);
		    total.add(canvas);
		    total.setPreferredSize(new Dimension(windowWidth, windowHeight+25));
		    
		    frame = new JFrame();
		    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		    frame.setResizable(false);
		    
		    frame.addWindowListener(new WindowListener() {
				
				@Override
				public void windowOpened(WindowEvent arg0) {
					
				}
				
				@Override
				public void windowIconified(WindowEvent arg0) {
					
				}
				
				@Override
				public void windowDeiconified(WindowEvent arg0) {
					
				}
				
				@Override
				public void windowDeactivated(WindowEvent arg0) {
					
				}
				
				@Override
				public void windowClosing(WindowEvent arg0) {
			         canvas.setEnabled(false);
			         canvas.dispose();
					
				}
				
				@Override
				public void windowClosed(WindowEvent arg0) {
					System.exit(0);
					
				}
				
				@Override
				public void windowActivated(WindowEvent arg0) {
					canvas.requestFocus();
				}
			});
		    
		    frame.add(menuBar);
		    frame.add(total);
		    frame.pack();
		    frame.setLocationRelativeTo(null);
		    frame.setVisible(true);
		    canvas.setFocusable(true);
		    canvas.requestFocus();
            canvas.start();
		}
		catch (SlickException e)
		{
			e.printStackTrace();
		}
	}