-
-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathgameinitialize.pas
More file actions
81 lines (62 loc) · 2.58 KB
/
gameinitialize.pas
File metadata and controls
81 lines (62 loc) · 2.58 KB
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
{
Copyright 2023-2024 Michalis Kamburelis, Eugene Loza.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{ Game initialization.
This unit is cross-platform.
It will be used by the platform-specific program or library file. }
unit GameInitialize;
interface
implementation
uses SysUtils,
CastleWindow, CastleLog, CastleUIControls, CastleSteam,
GameSteam
{$region 'Castle Initialization Uses'}
// The content here may be automatically updated by CGE editor.
, GameViewMain
{$endregion 'Castle Initialization Uses'};
var
Window: TCastleWindow;
{ One-time initialization of resources. }
procedure ApplicationInitialize;
begin
{ Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
Steam := TCastleSteam.Create(AppId);
{ Create TViewMain that will handle "main" view of the game.
Larger games may use multiple views,
e.g. TViewMainMenu ("main menu view"),
TViewPlay ("playing the game view"),
TViewCredits ("showing the credits view") etc. }
{$region 'Castle View Creation'}
// The content here may be automatically updated by CGE editor.
ViewMain := TViewMain.Create(Application);
{$endregion 'Castle View Creation'}
Window.Container.View := ViewMain;
end;
initialization
Randomize;
{ This initialization section configures:
- Application.OnInitialize
- Application.MainWindow
- determines initial window size
You should not need to do anything more in this initialization section.
Most of your actual application initialization (in particular, any file reading)
should happen inside ApplicationInitialize. }
Application.OnInitialize := @ApplicationInitialize;
Window := TCastleWindow.Create(Application);
Application.MainWindow := Window;
{ Optionally, adjust window fullscreen state and size at this point.
See https://castle-engine.io/window_size . }
// Fullscreen by default, makes Steam overlay look better
Window.FullScreen := true;
{ Handle command-line parameters like --fullscreen and --window.
By doing this last, you let user to override your fullscreen / mode setup. }
Window.ParseParameters;
end.