Debian Codegraph @

examples/mobile/activity_recognition/code/gameinitialize.pas

raw
1 { Game initialization.
2 This unit is cross-platform.
3 It will be used by the platform-specific program or library file. }
4 unit GameInitialize;
5
6 interface
7
8 implementation
9
10 uses CastleWindow, CastleLog, CastleApplicationProperties
11 {$region 'Castle Initialization Uses'}
12 // The content here may be automatically updated by CGE editor.
13 , GameViewMain
14 {$endregion 'Castle Initialization Uses'};
15
16 var
17 Window: TCastleWindow;
18
19 { One-time initialization of resources. }
20 procedure ApplicationInitialize;
21 begin
22 { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
23 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
24
25 { Create views (see https://castle-engine.io/views ). }
26 {$region 'Castle View Creation'}
27 // The content here may be automatically updated by CGE editor.
28 ViewMain := TViewMain.Create(Application);
29 {$endregion 'Castle View Creation'}
30
31 Window.Container.View := ViewMain;
32 end;
33
34 initialization
35 { This initialization section configures:
36 - Application.OnInitialize
37 - Application.MainWindow
38 - determines initial window size
39
40 You should not need to do anything more in this initialization section.
41 Most of your actual application initialization (in particular, any file reading)
42 should happen inside ApplicationInitialize. }
43
44 Application.OnInitialize := @ApplicationInitialize;
45
46 Window := TCastleWindow.Create(Application);
47 Application.MainWindow := Window;
48
49 { Optionally, adjust window fullscreen state and size at this point.
50 Examples:
51
52 Run fullscreen:
53
54 Window.FullScreen := true;
55
56 Run in a 600x400 window:
57
58 Window.FullScreen := false; // default
59 Window.Width := 600;
60 Window.Height := 400;
61
62 Run in a window taking 2/3 of screen (width and height):
63
64 Window.FullScreen := false; // default
65 Window.Width := Application.ScreenWidth * 2 div 3;
66 Window.Height := Application.ScreenHeight * 2 div 3;
67
68 Note that some platforms (like mobile) ignore these window sizes.
69 }
70 { On desktops, change the initial window size to simulate a tall screen,
71 like mobile in a "portrait" orientation. }
72 Window.Height := Application.ScreenHeight * 5 div 6;
73 Window.Width := Window.Height * 900 div 1600;
74
75 { Handle command-line parameters like --fullscreen and --window.
76 By doing this last, you let user to override your fullscreen / mode setup. }
77 Window.ParseParameters;
78 end.