public static void main(String[] args) {

        Simulation sim;
        MainCanvas canvas;

        int vSync = 100; //Number of FPS we have as upper limit

        final JFrame myFrame = new JFrame("Simulated Evolution"); //title

        myFrame.setSize(new Dimension(Constants.WIDTH + 6, Constants.HEIGHT + 28)); //Including offsets for the frame borders
        //myFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); //fullscreen
        //myFrame.setUndecorated(true); //noborder
        myFrame.setVisible(true);
        myFrame.setResizable(false);

        initWindowClose(myFrame);

        sim = new Simulation();
        canvas = new MainCanvas();
        canvas.setSimulation(sim);
        myFrame.add("Center", canvas);
        myFrame.addKeyListener(new MKeyListener());

        int sleep = 0;
        float res = 0;
        
        // Runs startup on the simulation.
        sim.start(80);
        
        for (int i = 0; i < 80; ++i) {
        	//sim.spawnHerbivore();
        }

        for (int i = 0; i < 20; ++i) {
        	//sim.spawnCarnivore();
        }
        
        for (int i = 0; i < 40; ++i) {
        	sim.spawnDying();
        }
         
        for (int i = 0; i < 80; ++i) {
        	sim.spawnRandom();
        }
        
        
        //Simulation loop
        while(true){

            long time = System.nanoTime();

            sim.run();
            canvas.paint();

            canvas.drawText(Integer.toString(sim.getTicks()/100) + "s", 0, 12);
            canvas.drawText(Integer.toString((int) res) + "%", 0, 24);
            canvas.update();

            time = System.nanoTime() - time;

            //We pause the thread a bit so we don't run it full speed
            sleep = (1000 / vSync) - (int) time / 1000000;

            if(sleep > 0){
                try {Thread.sleep((sleep));}
                catch (InterruptedException e) {e.printStackTrace();}
            }
            else{
                sleep = 0;
            }

            res = 1000 / ((time/1000000) + sleep);
        }
    }