~ubuntu-branches/ubuntu/utopic/castle-game-engine/utopic

« back to all changes in this revision

Viewing changes to examples/3d_sound_game/lets_take_a_walk.lpr

  • Committer: Package Import Robot
  • Author(s): Paul Gevers
  • Date: 2013-09-08 21:18:46 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130908211846-zzo3xbeb11fn1vil
Tags: 4.1.1-1
* New upstream release
  - Drop all patches, applied upstream
  - Add fp-units-net to Build-depends
* Add myself to uploaders
* Reorganize d/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
  public
75
75
    function PointingDeviceActivate(const Active: boolean;
76
76
      const Distance: Single): boolean; override;
77
 
    procedure Idle(const CompSpeed: Single; var RemoveMe: TRemoveType); override;
 
77
    procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
78
78
  end;
79
79
 
80
80
const
103
103
  Dec(TntsCount);
104
104
end;
105
105
 
106
 
procedure TTnt.Idle(const CompSpeed: Single; var RemoveMe: TRemoveType);
 
106
procedure TTnt.Update(const SecondsPassed: Single; var RemoveMe: TRemoveType);
107
107
var
108
108
  T: TVector3Single;
109
109
begin
113
113
  T := Translation;
114
114
  if T[2] > 0 then
115
115
  begin
116
 
    T[2] -= 5 * CompSpeed;
 
116
    T[2] -= 5 * SecondsPassed;
117
117
    MaxTo1st(T[2], 0);
118
118
    Translation := T;
119
119
  end;
158
158
function LoadScene(const Name: string; AOwner: TComponent): TCastleScene;
159
159
begin
160
160
  Result := TCastleScene.Create(AOwner);
161
 
  Result.Load(ProgramDataPath + 'data' + PathDelim + '3d' + PathDelim + Name);
 
161
  Result.Load(ApplicationData('3d/' + Name));
162
162
end;
163
163
 
164
164
type
193
193
 
194
194
const
195
195
  Version = '1.2.4';
196
 
  DisplayProgramName = 'lets_take_a_walk';
 
196
  DisplayApplicationName = 'lets_take_a_walk';
197
197
 
198
198
procedure ShowHelpMessage;
199
199
const
200
200
  HelpMessage = {$I help_message.inc};
201
201
begin
202
202
  MessageOK(Window, HelpMessage + nl +
203
 
    SCastleEngineProgramHelpSuffix(DisplayProgramName, Version, false), taLeft);
 
203
    SCastleEngineProgramHelpSuffix(DisplayApplicationName, Version, false), taLeft);
204
204
end;
205
205
 
206
206
{ window callbacks ----------------------------------------------------------- }
220
220
  TntScene.GLContextClose;
221
221
end;
222
222
 
223
 
procedure Idle(Window: TCastleWindowBase);
 
223
procedure Update(Window: TCastleWindowBase);
224
224
begin
225
225
  { update rat }
226
 
  RatAngle += 0.5 * Window.Fps.IdleSpeed;
 
226
  RatAngle += 0.5 * Window.Fps.UpdateSecondsPassed;
227
227
  UpdateRatPosition;
228
228
  if RatSound <> nil then
229
229
    RatSound.Position := Rat.Translation;
272
272
          nl+
273
273
          TCastleWindowBase.ParseParametersHelp(StandardParseOptions, true) +nl+
274
274
          nl+
275
 
          SCastleEngineProgramHelpSuffix(DisplayProgramName, Version, true));
 
275
          SCastleEngineProgramHelpSuffix(DisplayApplicationName, Version, true));
276
276
        ProgramBreak;
277
277
      end;
278
278
    1:begin
296
296
  Window := TCastleWindow.Create(Application);
297
297
  Window.OnClose := @close;
298
298
  Window.OnResize := @resize;
299
 
  Window.OnIdle := @Idle;
 
299
  Window.OnUpdate := @Update;
300
300
  Window.OnTimer := @Timer;
301
301
  Window.OnPress := @Press;
302
302
  Window.AutoRedisplay := true;
314
314
    as opening window calls Resize which uses MuteImage. }
315
315
  MuteImage := TCastleImageControl.Create(Application);
316
316
  MuteImage.Blending := true;
317
 
  MuteImage.FileName := ProgramDataPath + 'data' + PathDelim + 'textures' + PathDelim +'mute_sign.png';
 
317
  MuteImage.URL := ApplicationData('textures/mute_sign.png');
318
318
  MuteImage.Exists := false; // don't show it on initial progress
319
319
  Window.Controls.InsertFront(MuteImage);
320
320
 
359
359
  while TntsCount < MaxTntsCount do NewTnt(0.0);
360
360
 
361
361
  { init 3D sounds }
362
 
  SoundEngine.SoundsFileName := ProgramDataPath + 'data' +
363
 
    PathDelim + 'sounds' + PathDelim + 'index.xml';
 
362
  SoundEngine.RepositoryURL := ApplicationData('sounds/index.xml');
364
363
  SoundEngine.DistanceModel := dmInverseDistanceClamped; //< OpenAL default
365
364
  stRatSound  := SoundEngine.SoundFromName('rat_sound');
366
365
  stRatSqueak := SoundEngine.SoundFromName('rat_squeak');