Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Game.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: Game.h
7
AUTHOR: John DiCamillo
8
9
*/
10
11
#ifndef Game_h
12
#define Game_h
13
14
#include "
Types.h
"
15
#include "
Screen.h
"
16
#include "
Video.h
"
17
18
// +--------------------------------------------------------------------+
19
20
void
Print
(
const
char
* fmt, ...);
21
22
LRESULT CALLBACK
WndProc
(HWND, UINT, WPARAM, LPARAM);
23
24
void
FlushKeys
();
25
void
BufferKey
(
int
vkey);
26
int
GetKey
();
27
int
GetKeyPlus
(
int
& key,
int
& shift);
28
29
extern
"C"
bool
ProfileGameLoop
(
void
);
30
31
// +--------------------------------------------------------------------+
32
33
class
ContentBundle
;
34
class
Locale
;
35
class
Universe
;
36
class
Sound
;
37
class
SoundCard
;
38
class
Video
;
39
class
VideoFactory
;
40
class
VideoSettings
;
41
class
AviFile
;
42
class
Text
;
43
44
// +--------------------------------------------------------------------+
45
46
class
Game
47
{
48
public
:
49
static
const
char
*
TYPENAME
() {
return
"Game"
; }
50
enum
STATUS
{
OK
,
RUN
,
EXIT
,
PANIC
,
INIT_FAILED
,
TOO_MANY
};
51
52
Game
();
53
virtual
~Game
();
54
55
//
56
// MAIN GAME FUNCTIONALITY:
57
//
58
59
virtual
bool
Init
(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline,
int
nCmdShow);
60
virtual
int
Run
();
61
virtual
void
Exit
();
62
virtual
bool
OnPaint
() {
return
false
; }
63
virtual
bool
OnHelp
() {
return
false
; }
64
65
virtual
void
Activate
(
bool
f);
66
virtual
void
Pause
(
bool
f);
67
int
Status
()
const
{
return
status
; }
68
69
virtual
void
ScreenCapture
(
const
char
* name = 0);
70
virtual
void
AVICapture
(
const
char
* fname = 0);
71
72
const
RenderStats
&
GetPolyStats
() {
return
stats
; }
73
74
//
75
// GENERAL GAME CLASS UTILITY METHODS:
76
//
77
78
static
void
Panic
(
const
char
* msg=0);
79
static
bool
DisplayModeSupported
(
int
w,
int
h,
int
bpp);
80
static
int
MaxTexSize
();
81
static
int
MaxTexAspect
();
82
static
int
GammaLevel
();
83
static
void
SetGammaLevel
(
int
g);
84
static
void
SetMaxTexSize
(
int
n);
85
86
static
DWORD
RealTime
();
87
static
DWORD
GameTime
();
88
static
DWORD
TimeCompression
();
89
static
void
SetTimeCompression
(DWORD comp);
90
static
DWORD
Frame
();
91
static
void
ResetGameTime
();
92
static
void
SkipGameTime
(
double
seconds
);
93
94
static
double
FrameRate
();
95
static
double
FrameTime
();
96
static
double
GUITime
();
97
static
void
SetMaxFrameLength
(
double
seconds
) {
max_frame_length
=
seconds
; }
98
static
void
SetMinFrameLength
(
double
seconds
) {
min_frame_length
=
seconds
; }
99
static
double
GetMaxFrameLength
() {
return
max_frame_length
; }
100
static
double
GetMinFrameLength
() {
return
min_frame_length
; }
101
102
static
Game
*
GetInstance
();
103
static
Video
*
GetVideo
();
104
static
Color
GetScreenColor
();
105
static
void
SetScreenColor
(
Color
c);
106
static
int
GetScreenWidth
();
107
static
int
GetScreenHeight
();
108
109
static
bool
Active
() {
return
active
; }
110
static
bool
Paused
() {
return
paused
; }
111
static
bool
Server
() {
return
server
; }
112
static
bool
ShowMouse
() {
return
show_mouse
; }
113
static
bool
IsWindowed
();
114
115
static
HINSTANCE
GetHINST
();
116
static
HWND
GetHWND
();
117
118
static
void
UseLocale
(
Locale
* locale);
119
static
Text
GetText
(
const
char
* key);
120
121
static
const
char
*
GetPanicMessage
() {
return
panicbuf
; }
122
123
virtual
bool
GameLoop
();
124
virtual
void
UpdateWorld
();
125
virtual
void
GameState
();
126
virtual
void
UpdateScreen
();
127
virtual
void
CollectStats
();
128
129
virtual
bool
InitApplication
(HINSTANCE);
130
virtual
bool
InitInstance
(HINSTANCE,
int
);
131
virtual
bool
InitContent
();
132
virtual
bool
InitGame
();
133
virtual
bool
InitVideo
();
134
virtual
bool
ResizeVideo
();
135
virtual
bool
ResetVideo
();
136
virtual
bool
ToggleFullscreen
();
137
virtual
bool
AdjustWindowForChange
();
138
139
virtual
bool
SetupPalette
();
140
virtual
bool
LoadPalette
(PALETTEENTRY* pal, BYTE* inv);
141
virtual
void
ShowStats
();
142
143
protected
:
144
friend
bool
ProfileGameLoop
(
void
);
145
friend
LRESULT CALLBACK
WndProc
(HWND
hwnd
, UINT message, WPARAM uParam, LPARAM lParam);
146
147
ContentBundle
*
content
;
148
Universe
*
world
;
149
VideoFactory
*
video_factory
;
150
Video
*
video
;
151
VideoSettings
*
video_settings
;
152
SoundCard
*
soundcard
;
153
Screen
*
screen
;
154
int
gamma
;
155
int
max_tex_size
;
156
157
RenderStats
stats
;
158
DWORD
totaltime
;
159
160
PALETTEENTRY
standard_palette
[256];
161
BYTE
inverse_palette
[32768];
162
163
HINSTANCE
hInst
;
164
HWND
hwnd
;
165
HMENU
hmenu
;
166
DWORD
winstyle
;
167
168
char
*
app_name
;
169
char
*
title_text
;
170
char
*
palette_name
;
171
172
// Internal variables for the state of the app
173
bool
is_windowed
;
174
bool
is_active
;
175
bool
is_device_lost
;
176
bool
is_minimized
;
177
bool
is_maximized
;
178
bool
ignore_size_change
;
179
bool
is_device_initialized
;
180
bool
is_device_restored
;
181
DWORD
window_style
;
// Saved window style for mode switches
182
RECT
bounds_rect
;
// Saved window bounds for mode switches
183
RECT
client_rect
;
// Saved client area size for mode switches
184
185
186
double
gui_seconds
;
187
double
seconds
;
188
double
frame_rate
;
189
int
frame_count
;
190
int
frame_count0
;
191
int
frame_time
;
192
int
frame_time0
;
193
194
int
status
;
195
int
exit_code
;
196
Color
screen_color
;
197
198
AviFile
*
avi_file
;
199
200
static
bool
active
;
201
static
bool
paused
;
202
static
bool
server
;
203
static
bool
show_mouse
;
204
static
DWORD
base_game_time
;
205
static
DWORD
real_time
;
206
static
DWORD
game_time
;
207
static
DWORD
time_comp
;
208
static
DWORD
frame_number
;
209
210
static
double
max_frame_length
;
211
static
double
min_frame_length
;
212
213
static
char
panicbuf
[256];
214
};
215
216
// +--------------------------------------------------------------------+
217
218
#endif Game_h
219
220
nGenEx
Game.h
Generated on Tue Jun 5 2012 20:46:23 for Starshatter_Open by
1.8.1