Debian Codegraph @

examples/physics/physics_3d_collisions_layers/code/gameinitialize.pas

raw
1 {
2 Copyright 2023-2023 Michalis Kamburelis, Andrzej Kilijanski
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 For this example, run the project in the editor and test
17 different settings for the Items.PhysicsProperties.LayerCollisions.
18 The sources don't contain any interesting code about physics layers.
19 }
20 unit GameInitialize;
21
22 interface
23
24 implementation
25
26 uses SysUtils,
27 CastleWindow, CastleLog, CastleUIControls
28 {$region 'Castle Initialization Uses'}
29 // The content here may be automatically updated by CGE editor.
30 , GameViewMain
31 {$endregion 'Castle Initialization Uses'};
32
33 var
34 Window: TCastleWindow;
35
36 { One-time initialization of resources. }
37 procedure ApplicationInitialize;
38 begin
39 { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
40 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
41
42 { Create views (see https://castle-engine.io/views ). }
43 {$region 'Castle View Creation'}
44 // The content here may be automatically updated by CGE editor.
45 ViewMain := TViewMain.Create(Application);
46 {$endregion 'Castle View Creation'}
47
48 Window.Container.View := ViewMain;
49 end;
50
51 initialization
52 { This initialization section configures:
53 - Application.OnInitialize
54 - Application.MainWindow
55 - determines initial window size
56
57 You should not need to do anything more in this initialization section.
58 Most of your actual application initialization (in particular, any file reading)
59 should happen inside ApplicationInitialize. }
60
61 Application.OnInitialize := @ApplicationInitialize;
62
63 Window := TCastleWindow.Create(Application);
64 Application.MainWindow := Window;
65
66 { Optionally, adjust window fullscreen state and size at this point.
67 Examples:
68
69 Run fullscreen:
70
71 Window.FullScreen := true;
72
73 Run in a 600x400 window:
74
75 Window.FullScreen := false; // default
76 Window.Width := 600;
77 Window.Height := 400;
78
79 Run in a window taking 2/3 of screen (width and height):
80
81 Window.FullScreen := false; // default
82 Window.Width := Application.ScreenWidth * 2 div 3;
83 Window.Height := Application.ScreenHeight * 2 div 3;
84
85 Note that some platforms (like mobile) ignore these window sizes.
86 }
87
88 { Handle command-line parameters like --fullscreen and --window.
89 By doing this last, you let user to override your fullscreen / mode setup. }
90 Window.ParseParameters;
91 end.