-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuClasses.pas
340 lines (284 loc) · 6.57 KB
/
uClasses.pas
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
//* Àâòîð [Xakep] *//
unit uClasses;
interface
uses
HKStreamCol, Classes, SysUtils, GLScene, GLObjects, OffSetAnim,
GLAnimatedSprite, GLFireFX, GLColor, GLScreen, Forms, Bass,
uInterfaces, uRooms, uEffects, VectorTypes, VectorGeometry,
GLHUDObjects, GLBitmapFontNFW;
type
TDevice = class
public
Width: Integer;
Height: Integer;
BPP: Integer;
FrameRate: Integer;
procedure SterParam(pWidth, pHeight, pBPP, pFrameRate: Integer);
procedure FullScreen; overload;
procedure FullScreen(Form: TForm); overload;
procedure Windowed; overload;
procedure Windowed(Form: TForm); overload;
end;
TPak = class(THKStreams)
public
mStream: TMemoryStream;
Files: TStringList;
FilesCount: Integer;
MainDir: String;
procedure Init;
procedure OpenPak(const FileName: String);
function ExtractFormPak(const ID: String): String;
procedure ClosePak;
constructor Create;
end;
TBPoint = class(TGLAnimatedSprite)
public
Eff: TGLDummyCube;
Explode: TGLFireFXManager;
procedure Init;
end;
TBall = class(TGLPlane)
public
Timer: Integer;
vx,vy: Integer;
Dir: Integer;
end;
TEnemy = class(TGLPlane)
private
fg: Single;
public
Anim: TOffSetAnim;
Timer: Integer;
Dir: Integer;
Health: Integer;
God: Boolean;
procedure Die;
constructor Create(AOwner: TComponent); override;
end;
TGame = class
public
onMusic: Boolean;
onSound: Boolean;
BassStream: HStream;
MainDir: String;
CurrentLevel: Integer;
GameOver: Boolean;
Score: Integer;
Lives: Integer;
Timer: Integer;
BScore: Integer;
BLives: Integer;
MaxPosCam: TVector2f;
Points: TStringList;
Player: TGLBaseSceneObject;
PPX,PPY: Single;
isLoad: Boolean;
isHS: Boolean;
isHS2: Boolean;
ScoreTable: TStringList;
White: TGLHUDSprite;
Black: TGLHUDSprite;
Dialog: TGLHUDText;
ReadDialog: Boolean;
DialogTimer: Integer;
DialogTimer2: Integer;
TitleTimer: Integer;
HelpText: array[1..9] of String;
MainFont: TGLBitmapFontNFW;
TitleFont: TGLBitmapFontNFW;
Objects: array of array of TGLBaseSceneObject;
CollisionsList: TList;
StepsList: TList;
ButtonsList: TList;
//
PanelsManager: TPanelsManager;
RoomsManager: TRoomsManager;
procedure Save(const FileName: String);
procedure Load(const FileName: String);
procedure NullAll;
constructor Create;
end;
implementation
//* TGPak *//
procedure TPak.Init;
begin
mStream:= TMemoryStream.Create;
Files:= TStringList.Create;
FilesCount:= 0;
end;
procedure TPak.OpenPak(const FileName: String);
begin
LoadFromFile(FileName);
end;
function TPak.ExtractFormPak(const ID: String): String;
begin
FilesCount:= FilesCount + 1;
mStream.Clear;
GetStream(ID,mStream);
mStream.SaveToFile(MainDir + '\Packeges\Temp\Pak_' + IntToStr(FilesCount) + ExtractFileExt(ID));
Files.Add(MainDir + '\Packeges\Temp\Pak_' + IntToStr(FilesCount) + ExtractFileExt(ID));
result:= MainDir + '\Packeges\Temp\Pak_' + IntToStr(FilesCount) + ExtractFileExt(ID);
end;
procedure TPak.ClosePak;
Var
i: Integer;
begin
for i:= 0 to Files.Count - 1 do DeleteFile(PCHar(Files.Strings[i]));
Files.Clear;
ClearStreams;
FilesCount:= 0;
end;
constructor TPak.Create;
begin
inherited Create(nil);
mStream:= TMemoryStream.Create;
Files:= TStringList.Create;
end;
{ TBPoint }
procedure TBPoint.Init;
begin
Explode:= TGLFireFXManager.Create(nil);
Eff:= TGLDummyCube(Scene.Objects.AddNewChild(TGLDummyCube));
Eff.Scale.SetVector(0.15,0.15,0.15);
with Explode do
begin
Disabled:= True;
InnerColor.Color:= clrWhite;
OuterColor.Color:= clrGray;
ParticleLife:= 5;
ParticleSize:= 5;
FireBurst:= 0;
FireDensity:= 0.5;
FireRadius:= 0.1;
MaxParticles:= 20;
end;
Eff.Position:= Position;
Eff.MoveLast;
GetOrCreateFireFX(Eff).Manager:= Explode;
end;
{ TDevice }
procedure TDevice.SterParam(pWidth, pHeight, pBPP, pFrameRate: Integer);
begin
Width:= pWidth;
Height:= pHeight;
BPP:= pBPP;
FrameRate:= pFrameRate;
end;
procedure TDevice.FullScreen;
Var
Resolution: TResolution;
begin
Resolution:= GetIndexFromResolution(Width,Height,BPP);
SetFullscreenMode(Resolution,FrameRate);
end;
procedure TDevice.FullScreen(Form: TForm);
Var
Resolution: TResolution;
begin
Resolution:= GetIndexFromResolution(Width,Height,BPP);
SetFullscreenMode(Resolution,FrameRate);
Form.ClientWidth:= Width;
Form.ClientHeight:= Height;
Form.Left:= 0;
Form.Top:= 0;
Form.BorderStyle:= bsNone;
end;
procedure TDevice.Windowed;
begin
SetFullscreenMode(0,100);
end;
procedure TDevice.Windowed(Form: TForm);
begin
SetFullscreenMode(0,100);
Form.ClientWidth:= Width;
Form.ClientHeight:= Height;
Form.Position:= poScreenCenter;
Form.BorderStyle:= bsSingle;
Form.BorderIcons:= [biSystemMenu,biMinimize];
end;
{ TGame }
procedure TGame.Save(const FileName: String);
Var
F: TextFile;
i: Integer;
begin
AssignFile(F,FileName);
Rewrite(F);
WriteLn(F,Score);
WriteLn(F,Lives);
WriteLn(F,BScore);
WriteLn(F,BLives);
WriteLn(F,CurrentLevel);
WriteLn(F,Format('%.3f',[Player.Position.X]));
WriteLn(F,Format('%.3f',[Player.Position.Y]));
for i:= 0 to Points.Count - 1 do
if Trim(Points[i]) <> '' then
WriteLn(F,Points[i]);
CloseFile(F);
end;
procedure TGame.Load(const FileName: String);
Var
F: TextFile;
S: String;
begin
GameOver:= False;
AssignFile(F,FileName);
Reset(F);
ReadLn(F,Score);
ReadLn(F,Lives);
ReadLn(F,BScore);
ReadLn(F,BLives);
ReadLn(F,CurrentLevel);
ReadLn(F,S);
PPX:= StrToFloat(S);
ReadLn(F,S);
PPY:= StrToFloat(S);
Points.Clear;
while not EOF(F) do
begin
ReadLn(F,S);
if Trim(S) <> '' then
Points.Add(S);
end;
CloseFile(F);
isLoad:= True;
Timer:= 0;
RoomsManager.GoToRoom('Level');
end;
constructor TGame.Create;
begin
inherited Create;
Points:= TStringList.Create;
CollisionsList:= TList.Create;
ButtonsList:= TList.Create;
StepsList:= TList.Create;
DialogTimer:= 0;
TitleTimer:= 0;
end;
procedure TGame.NullAll;
begin
Timer:= 0;
Score:= 0;
Lives:= 9;
BScore:= 0;
BLives:= 9;
GameOver:= False;
end;
//* TEnemy *//
constructor TEnemy.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fg:= 0.1;
end;
procedure TEnemy.Die;
begin
Tag:= -1;
if Material.FrontProperties.Diffuse.Alpha > 0 then
begin
Material.FrontProperties.Diffuse.Alpha := Material.FrontProperties.Diffuse.Alpha - 0.01;
fg := fg - 0.01;
Position.Y := Position.Y + fg;
Roll(-5*dir);
end else Destroy;
end;
end.