public SpaceInvaders() {
		
		//Key bindings
		createKeybindings();
		
		//Graphics
		createSprites();
		
		//Create HitBoxManager for managing collisions
		hitBoxManager = new HitBoxManager(20);
		
		//Entities
		createEntities();
		updateEntities = new Timer(20, new ActionListener() {

			int  framerate  = 0;
			long timePassed = 0;
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				long curTime = System.currentTimeMillis();
				if(timePassed < 1000) {
					framerate++;
					timePassed += 20+System.currentTimeMillis()-curTime;
				} else {timePassed = 0; framerate = 0;}
				updateInvaders();
				updatePlayer();
				updateMissiles();
			}
			
		});
		updateEntities.setRepeats(true);
		updateEntities.start();
		
		//Stop threads and timers on close
		this.addAncestorListener(new AncestorListener() {

			@Override
			public void ancestorRemoved(AncestorEvent e) {
				stopThreads();
				System.gc();
			}

			@Override
			public void ancestorAdded(AncestorEvent event) {}

			@Override
			public void ancestorMoved(AncestorEvent event) {}
			
		});
		
	}