how to create a new game loop in java

Solutions on MaxInterview for how to create a new game loop in java by the best coders in the world

showing results for - "how to create a new game loop in java"
Isabelle
02 Feb 2019
1public class Main implements Runnable{
2	public Thread thread;
3	private Boolean running = false;
4	public BufferStrategy bs;
5	public Graphics g;
6	
7	public Main() {
8		
9	}
10	
11	
12	private void init() {
13		Display display = new Display();
14	}
15	
16	
17	private void Update() {
18		
19	}
20	
21	
22	private void Render() {
23		
24	}
25	
26	
27	
28	public void run() {
29		init();
30		
31		while(running) {
32			Update();
33			Render();
34		}
35		
36		stop();
37	}
38	
39	
40	
41	public synchronized void start() {
42		if (running) 
43			return;
44		thread = new Thread(this);
45		thread.start();
46	}
47	
48	
49	
50	public synchronized void stop() {
51		if (!running) 
52			return;
53		running = false;
54		try {
55			thread.join();
56		} catch (Exception e){
57			
58		}
59	}
60}