@Override
	public void actionPerformed(ActionEvent e) 
	{
		boolean isMainReplaced = false;
		float timeStep = 1.0f / 30.f;
		int velocityIterations = 6;
		int positionIterations = 2;
		stage.getWorldController().getWorld().step(timeStep, velocityIterations, positionIterations);
		
		// Controls positions and angles of objects
		for (GameObject obj: stage.getWorldController().getObjects()) {
			obj.rotate(obj.body.getAngle());
			obj.setPos(obj.body.getPosition());
			if ( obj.isMain() && !obj.isInside())
				isMainReplaced = true;

		}
		// Destroy objects outside of the screen
		stage.destroyOutside();
		
		// add listeners to new main ball
		if (isMainReplaced){
			panel.addMouseListener(new controller.BallController(panel.getStage().getMainBall()));
			panel.addKeyListener(new controller.KeyboardController(panel.getStage().getMainBall()));
		}


		// Checks finish condition		
		if(stage.getFlag().isFinished(stage.getMainBall().getPos()))
			panel.won();
		
		// Checks if main ball captured by launcher
		if(stage.haveLauncher() != null ) {
				if(stage.haveLauncher().isCaptured(stage.getMainBall().getPos())){
					panel.pause();
					panel.launch();
				}
		}
		
		//update the time view
		if( !view.isPaused()) {
			incrementTime();
			view.setTime(min, sec);
		}
		
		// Repaint screen
		panel.repaint();
	}