| 1 |
{ |
| 2 |
Copyright 2020-2022 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 |
{ Main view, where most of the application logic takes place. } |
| 17 |
unit GameViewMain; |
| 18 |
|
| 19 |
interface |
| 20 |
|
| 21 |
uses Classes, |
| 22 |
CastleVectors, CastleComponentSerialize, |
| 23 |
CastleUIControls, CastleControls, CastleKeysMouse, CastleViewport, CastleTransform; |
| 24 |
|
| 25 |
type |
| 26 |
{ Main view, where most of the application logic takes place. } |
| 27 |
TViewMain = class(TCastleView) |
| 28 |
published |
| 29 |
{ Components designed using CGE editor. |
| 30 |
These fields will be automatically initialized at Start. } |
| 31 |
DesignContent: TCastleDesign; |
| 32 |
ButtonHingeSimple: TCastleButton; |
| 33 |
ButtonHingeBreakable: TCastleButton; |
| 34 |
ButtonHingeCar: TCastleButton; |
| 35 |
ButtonHingeLimits: TCastleButton; |
| 36 |
ButtonDistance: TCastleButton; |
| 37 |
ButtonDistanceSpring: TCastleButton; |
| 38 |
ButtonRope: TCastleButton; |
| 39 |
ButtonRopeChain: TCastleButton; |
| 40 |
private |
| 41 |
procedure ClickHingeSimple(Sender: TObject); |
| 42 |
procedure ClickHingeBreakable(Sender: TObject); |
| 43 |
procedure ClickHingeCar(Sender: TObject); |
| 44 |
procedure ClickHingeLimits(Sender: TObject); |
| 45 |
procedure ClickDistance(Sender: TObject); |
| 46 |
procedure ClickDistanceSpring(Sender: TObject); |
| 47 |
procedure ClickRope(Sender: TObject); |
| 48 |
procedure ClickRopeChain(Sender: TObject); |
| 49 |
public |
| 50 |
constructor Create(AOwner: TComponent); override; |
| 51 |
procedure Start; override; |
| 52 |
end; |
| 53 |
|
| 54 |
var |
| 55 |
ViewMain: TViewMain; |
| 56 |
|
| 57 |
implementation |
| 58 |
|
| 59 |
uses SysUtils; |
| 60 |
|
| 61 |
{ TViewMain ----------------------------------------------------------------- } |
| 62 |
|
| 63 |
constructor TViewMain.Create(AOwner: TComponent); |
| 64 |
begin |
| 65 |
inherited; |
| 66 |
DesignUrl := 'castle-data:/gameviewmain.castle-user-interface'; |
| 67 |
end; |
| 68 |
|
| 69 |
procedure TViewMain.Start; |
| 70 |
begin |
| 71 |
inherited; |
| 72 |
ButtonHingeSimple.OnClick := {$ifdef FPC}@{$endif} ClickHingeSimple; |
| 73 |
ButtonHingeBreakable.OnClick := {$ifdef FPC}@{$endif} ClickHingeBreakable; |
| 74 |
ButtonHingeCar.OnClick := {$ifdef FPC}@{$endif} ClickHingeCar; |
| 75 |
ButtonHingeLimits.OnClick := {$ifdef FPC}@{$endif} ClickHingeLimits; |
| 76 |
ButtonDistance.OnClick := {$ifdef FPC}@{$endif} ClickDistance; |
| 77 |
ButtonDistanceSpring.OnClick := {$ifdef FPC}@{$endif} ClickDistanceSpring; |
| 78 |
ButtonRope.OnClick := {$ifdef FPC}@{$endif} ClickRope; |
| 79 |
ButtonRopeChain.OnClick := {$ifdef FPC}@{$endif} ClickRopeChain; |
| 80 |
end; |
| 81 |
|
| 82 |
procedure TViewMain.ClickHingeSimple(Sender: TObject); |
| 83 |
begin |
| 84 |
DesignContent.Url := 'castle-data:/2d_joint_hinge_simple_example.castle-user-interface'; |
| 85 |
end; |
| 86 |
|
| 87 |
procedure TViewMain.ClickHingeBreakable(Sender: TObject); |
| 88 |
begin |
| 89 |
DesignContent.Url := 'castle-data:/2d_joint_hinge_break_force_example.castle-user-interface'; |
| 90 |
end; |
| 91 |
|
| 92 |
procedure TViewMain.ClickHingeCar(Sender: TObject); |
| 93 |
begin |
| 94 |
DesignContent.Url := 'castle-data:/2d_joint_hinge_car.castle-user-interface'; |
| 95 |
end; |
| 96 |
|
| 97 |
procedure TViewMain.ClickHingeLimits(Sender: TObject); |
| 98 |
begin |
| 99 |
DesignContent.Url := 'castle-data:/2d_joint_hinge_limits_example.castle-user-interface'; |
| 100 |
end; |
| 101 |
|
| 102 |
procedure TViewMain.ClickDistance(Sender: TObject); |
| 103 |
begin |
| 104 |
DesignContent.Url := 'castle-data:/2d_joint_distance_example.castle-user-interface'; |
| 105 |
end; |
| 106 |
|
| 107 |
procedure TViewMain.ClickDistanceSpring(Sender: TObject); |
| 108 |
begin |
| 109 |
DesignContent.Url := 'castle-data:/2d_joint_distance_spring_example.castle-user-interface'; |
| 110 |
end; |
| 111 |
|
| 112 |
procedure TViewMain.ClickRope(Sender: TObject); |
| 113 |
begin |
| 114 |
DesignContent.Url := 'castle-data:/2d_joint_rope_simple.castle-user-interface'; |
| 115 |
end; |
| 116 |
|
| 117 |
procedure TViewMain.ClickRopeChain(Sender: TObject); |
| 118 |
begin |
| 119 |
DesignContent.Url := 'castle-data:/2d_joint_rope_chain.castle-user-interface'; |
| 120 |
end; |
| 121 |
|
| 122 |
end. |