-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screen.java
99 lines (82 loc) · 1.73 KB
/
Screen.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Font;
public class Screen extends JPanel
{
//Instance Variables
private int fps,ups;
private boolean paused=false,running=true;
private Screen next=null;
//Construtors
public Screen()
{
setBackground(Color.RED.darker());
}
//Mutators
//only for things that happen every frame
public void update()
{
}
public void render(double interpolation)
{
repaint();
}
protected void drawScene(Graphics g)
{
}
protected void drawUI(Graphics g)
{
g.setColor(Color.WHITE);
g.setFont(new Font(Font.DIALOG_INPUT,Font.BOLD,20));
//bottom right
g.drawString("UPS: "+ups,getWidth()*3/4,getHeight()-50);
g.drawString("FPS: "+fps,getWidth()*3/4,getHeight()-25);
}
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(next==null)
{
//draw everything not related to UI below UI
drawScene(g);
//draw info on top of everything
drawUI(g);
}
}
//Setters
public void setFps(int f)
{
fps=f;
}
public void setUps(int u)
{
ups=u;
}
public void setPaused(boolean p)
{
paused=p;
}
public void setRunning(boolean r)
{
running=r;
}
public void setNext(Screen n)
{
next=n;
}
//Getters
public boolean isPaused()
{
return paused;
}
public boolean isRunning()
{
return running;
}
public Screen getNext()
{
return next;
}
}