fill
0
Q:

How to create a new game loop in java

public class Main implements Runnable{
	public Thread thread;
	private Boolean running = false;
	public BufferStrategy bs;
	public Graphics g;
	
	public Main() {
		
	}
	
	
	private void init() {
		Display display = new Display();
	}
	
	
	private void Update() {
		
	}
	
	
	private void Render() {
		
	}
	
	
	
	public void run() {
		init();
		
		while(running) {
			Update();
			Render();
		}
		
		stop();
	}
	
	
	
	public synchronized void start() {
		if (running) 
			return;
		thread = new Thread(this);
		thread.start();
	}
	
	
	
	public synchronized void stop() {
		if (!running) 
			return;
		running = false;
		try {
			thread.join();
		} catch (Exception e){
			
		}
	}
}
1

New to Communities?

Join the community