forked from p0nce/Wormhol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamecontext.d
109 lines (91 loc) · 2.5 KB
/
gamecontext.d
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
100
101
102
103
104
105
106
107
108
109
module gamecontext;
import res.shaderpool;
import res.textures;
import postprocessing;
import math.vec2;
import math.box2;
import bitmapfont;
import misc.logger;
import sound;
/**
* Game information needed by states.
*/
class GameContext
{
private
{
PostProcessing m_postProcessing;
vec2i m_size;
ShaderPool m_shaderPool;
SoundManager m_soundManager;
Textures m_textures;
BitmapFont m_font;
box2i m_viewport;
vec2f m_mousePos;
vec2f m_mouseVel;
bool m_mouseDown = false;
}
public
{
this(PostProcessing postProcessing, vec2i size, ShaderPool shaderPool, Textures textures,
BitmapFont font, box2i viewport, SoundManager soundManager)
{
info(">GameContext.this");
m_postProcessing = postProcessing;
m_size = size;
m_shaderPool = shaderPool;
m_textures = textures;
m_font = font;
m_viewport = viewport;
m_soundManager = soundManager;
info("<GameContext.this");
}
Textures textures() { return m_textures; }
int width() { return m_size.x; }
int height() { return m_size.y; }
float blurAmount(float ba) { return m_postProcessing.blurAmount = ba; }
float PPAmount(float ppa) { return m_postProcessing.PPAmount = ppa; }
float HFAmount(float hfa) { return m_postProcessing.HFAmount = hfa; }
float blurAmount() { return m_postProcessing.blurAmount; }
float PPAmount() { return m_postProcessing.PPAmount; }
float HFAmount() { return m_postProcessing.HFAmount; }
ShaderPool shaderPool() { return m_shaderPool; }
BitmapFont font() { return m_font; }
box2i viewport()
{
return m_viewport;
}
double ratio()
{
return m_viewport.width / m_viewport.height;
}
bool mouseDown()
{
return m_mouseDown;
}
bool mouseDown(bool b)
{
return m_mouseDown = b;
}
vec2f mousePos()
{
return m_mousePos;
}
vec2f mousePos(vec2f pos)
{
return m_mousePos = pos;
}
vec2f mouseVel()
{
return m_mouseVel;
}
vec2f mouseVel(vec2f vel)
{
return m_mouseVel = vel;
}
SoundManager soundManager()
{
return m_soundManager;
}
}
}