Debian Codegraph @

examples/creature_behaviors/code/gamesounds.pas

raw
1 {
2 Copyright 2024-2024 Andrzej Kilijański, 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 { Manage the repository of sounds (useful from any view).
17
18 Usage:
19 - Configure sounds using CGE editor by editing data/audio/sounds.castle-component ,
20 - From code:
21 - Call once InitializeSounds (e.g. from ApplicationInitialize)
22 - Use SoundXxx variables freely, they should non-nil.
23 Treat them as read-only, don't modify them. }
24 unit GameSounds;
25
26 interface
27
28 uses CastleSoundEngine;
29
30 procedure InitializeSounds;
31
32 var
33 SoundMusic: TCastleSound;
34 SoundShoot: TCastleSound;
35
36 implementation
37
38 uses Classes,
39 CastleWindow, CastleComponentSerialize;
40
41 procedure InitializeSounds;
42 var
43 { Owner of components loaded from sounds.castle-component. }
44 Sounds: TComponent;
45 begin
46 Sounds := TComponent.Create(Application);
47 ComponentLoad('castle-data:/audio/sounds.castle-component', Sounds);
48 SoundMusic := Sounds.FindRequiredComponent('SoundMusic') as TCastleSound;
49 SoundShoot := Sounds.FindRequiredComponent('SoundShoot') as TCastleSound;
50 end;
51
52 end.