{ Copyright 2022-2023 Michalis Kamburelis. This file is part of "Castle Game Engine". "Castle Game Engine" is free software; see the file COPYING.txt, included in this distribution, for details about the copyright. "Castle Game Engine" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---------------------------------------------------------------------------- } { Main view handles playing the game. } unit GameViewMain; interface uses Classes, CastleCameras, CastleVectors, CastleUIControls, CastleControls, CastleKeysMouse; type TViewMain = class(TCastleView) published { Components designed using CGE editor. These fields will be automatically initialized at Start. } WalkNavigation: TCastleWalkNavigation; LabelFps: TCastleLabel; public constructor Create(AOwner: TComponent); override; procedure Start; override; procedure Update(const SecondsPassed: Single; var HandleInput: Boolean); override; function Press(const Event: TInputPressRelease): Boolean; override; end; var ViewMain: TViewMain; implementation constructor TViewMain.Create(AOwner: TComponent); begin inherited; DesignUrl := 'castle-data:/gameviewmain.castle-user-interface'; end; procedure TViewMain.Start; begin inherited; end; procedure TViewMain.Update(const SecondsPassed: Single; var HandleInput: Boolean); begin inherited; LabelFps.Caption := Container.Fps.ToString; end; function TViewMain.Press(const Event: TInputPressRelease): Boolean; begin Result := inherited; if Result then Exit; // allow the ancestor to handle keys if Event.IsKey(keyF4) then begin WalkNavigation.MouseLook := not WalkNavigation.MouseLook; Exit(true); end; end; end.