Debian Codegraph @

examples/animations/simultaneous_animations_one_scene/code/gameinitialize.pas

raw
1 {
2 Copyright 2019-2023 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Game initialization and logic. }
17 unit GameInitialize;
18
19 interface
20
21 implementation
22
23 uses SysUtils, Classes,
24 CastleWindow, CastleScene, CastleControls, CastleLog, CastleVectors,
25 CastleFilesUtils, CastleSceneCore, CastleViewport, CastleComponentSerialize,
26 CastleUIControls, CastleApplicationProperties, X3DNodes
27 {$region 'Castle Initialization Uses'}
28 // The content here may be automatically updated by CGE editor.
29 , GameViewMain
30 {$endregion 'Castle Initialization Uses'};
31
32 var
33 Window: TCastleWindow;
34
35 { One-time initialization of resources. }
36 procedure ApplicationInitialize;
37 begin
38 { Adjust container settings for a scalable UI. }
39 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
40
41 { Create views (see https://castle-engine.io/views ). }
42 {$region 'Castle View Creation'}
43 // The content here may be automatically updated by CGE editor.
44 ViewMain := TViewMain.Create(Application);
45 {$endregion 'Castle View Creation'}
46
47 Window.Container.View := ViewMain;
48 end;
49
50 initialization
51 { This initialization section configures:
52 - Application.OnInitialize
53 - Application.MainWindow
54 - determines initial window size
55
56 You should not need to do anything more in this initialization section.
57 Most of your actual application initialization (in particular, any file reading)
58 should happen inside ApplicationInitialize. }
59
60 Application.OnInitialize := @ApplicationInitialize;
61
62 Window := TCastleWindow.Create(Application);
63 Application.MainWindow := Window;
64
65 { Optionally, adjust window fullscreen state and size at this point.
66 Examples:
67
68 Run fullscreen:
69
70 Window.FullScreen := true;
71
72 Run in a 600x400 window:
73
74 Window.FullScreen := false; // default
75 Window.Width := 600;
76 Window.Height := 400;
77
78 Run in a window taking 2/3 of screen (width and height):
79
80 Window.FullScreen := false; // default
81 Window.Width := Application.ScreenWidth * 2 div 3;
82 Window.Height := Application.ScreenHeight * 2 div 3;
83
84 Note that some platforms (like mobile) ignore these window sizes.
85 }
86
87 { Handle command-line parameters like --fullscreen and --window.
88 By doing this last, you let user to override your fullscreen / mode setup. }
89 Window.ParseParameters;
90 end.