home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-15 | 6.5 KB | 297 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { FSIntf.p }
- {}
- { Interface file for the Flight Stability application. }
- {}
- { Copyright © 1995, Patrick Hew. All rights reserved. }
- {}
- {****************************************************}
-
-
- unit FSIntf;
-
- interface
-
- uses
- TCL, TCL_Controls, FW_Tearoffs, CBitmapWindow, Vector3;
-
- const
-
-
- { Window dimensions. Used to locate at the centre of the main screen. }
-
- kFSGameWindh = 318;
- kFSGameWindv = 434;
-
- kFSHelpWindh = 318;
- kFSHelpWindv = 434;
-
-
- { Resource IDs. }
-
- WINDGame = 3000;
- WINDHelp = 4000;
-
- PICTHelpCredits = 4000;
- PICTHelpFlying = 4001;
- PICTHelpStability = 4002;
- PICTHelpDrawing = 4003;
-
- { Command IDs. }
-
- cmdTakeControl = 3000;
- cmdReleaseControl = 3001;
-
- cmdModeCredits = 4000;
- cmdModeFlying = 4001;
- cmdModeStability = 4002;
- cmdModeDrawing = 4003;
-
-
- {****}
- { * CFSAircraftPane }
- { *}
- { * Pane class to draw the perspective projection of the aircraft }
- { * which it is also responsible for. This is in lieu of making the }
- { * aircraft a separate object, which would have been the correct }
- { * thing to do, if it didn't look like being so involved to get it right. }
- { *}
- { * The aircraft model isn't quite right either, but its the way it is }
- { * because it is a lot easier to draw. }
- { *}
- { ****}
-
- const
- kAircraftPaneLenh = 300;
- kAircraftPaneLenv = 240;
-
- type
- CFSAircraftPane = object(CPane)
-
- { Parts of the aircraft. }
- noseCentre, noseLeft, noseRight: array[1..3] of V3Type;
- cockpitFront, cockpitBack: array[1..4] of V3Type;
- fuselageTopLeft, fuselageTopCentre, fuselageTopRight: array[1..4] of V3Type;
- fuselageBottomLeft, fuselageBottomCentre, fuselageBottomRight: array[1..4] of V3Type;
- leftWing, rightWing, leftTail, rightTail, tailFin: array[1..4] of V3Type;
- intake: array[1..2] of V3Type;
-
- { The current dynamics of the aircraft. }
- itsBank, itsAOA: Real;
-
- procedure IFSAircraftPane (anEnclosure: CView; aSupervisor: CBureaucrat; aWidth, aHeight, aHEncl, aVEncl: integer; aHSizing, aVSizing: SizingOption);
-
- procedure UpdateAircraft (aBank, aAOA: Real);
-
- procedure Draw (var area: Rect);
- override;
-
- end;
-
-
- {****}
- { * CFSApp}
- { *}
- { * Application class for Flight Stability.}
- { *}
- { ****}
-
- type
- CFSApp = object(CApplication)
-
- itsGameDirector: CFSGameDirector;
- itsHelpDirector: CFSHelpDirector;
-
- procedure IFSApp;
-
- procedure SetUpFileParameters;
- override;
-
- procedure MakeDesktop;
- override;
-
- procedure DoCommand (theCommand: longint);
- override;
-
- procedure StartUpAction (numPreloads: Integer);
- override;
-
- procedure ExitApp;
- override;
-
- end;
-
-
- {****}
- { * CFSGameDirector}
- { *}
- { * Director class for the Flight Stability application's game window.}
- { *}
- { ****}
-
- type
- CFSGameDirector = object(CDirector)
-
- itsAircraftPane: CFSAircraftPane;
- itsAutopilotButton: CButton;
- itsBankCheckBox, itsAOACheckBox: CCheckBox;
- itsDirFieldPane: CFSDirFieldPane;
- itsStickPane: CFSStickPane;
-
- { Whether we are on manual or automatic pilot. }
- isManual: Boolean;
-
- procedure IFSGameDirector (aSupervisor: CDirectorOwner);
-
- procedure Free;
- override;
-
- procedure BuildWindow;
-
- procedure UpdateMenus;
- override;
-
- procedure DoCommand (theCommand: longint);
- override;
-
- procedure DoKeyDown (theChar: char; keyCode: Byte; macEvent: EventRecord);
- override;
-
- procedure ProviderChanged (aProvider: CCollaborator; reason: Longint; info: univ Ptr);
- override;
-
- procedure Dawdle (var maxSleep: longint);
- override;
-
- end;
-
-
- {***}
- { * CFSHelpDirector}
- { *}
- { * Director class for the Flight Stability application's help window.}
- { *}
- { ***}
-
- type
- HelpMode = (ModeCredits, ModeFlying, ModeStability, ModeDrawing);
-
- type
- CFSHelpDirector = object(CDirector)
-
- itsMode: HelpMode;
- itsPicture: CPicture;
- itsCreditsButton, itsFlyingButton, itsStabilityButton, itsDrawingButton: CButton;
-
- procedure IFSHelpDirector (aSupervisor: CDirectorOwner);
-
- procedure Free;
- override;
-
- procedure BuildWindow;
-
- procedure DoCommand (theCommand: longint);
- override;
-
- procedure DrawHelpWindow (aMode: HelpMode);
-
- end;
-
-
- {***}
- { * CFSDirFieldPane}
- { *}
- { * Pane class for the direction field.}
- { *}
- { ***}
-
- const
- kDirFieldHalfWidth = 32 * 3;
- kDirFieldHalfHeight = 32 * 2;
-
- { Bank ranges from -pi to pi }
- { AOA ranges from -pi/2 to pi/2 }
- { Edges of direction field pane are ± pi }
-
- kBankToFrame = 30.558; { kDirFieldHalfWidth / pi }
- kFrameToBank = 0.0327; { pi / kDirFieldHalfWidth }
- kAOAToFrame = 40.744; { kDirFieldHalfHeight / (pi/2) }
- kFrameToAOA = 0.0245; { (pi/2) / kDirFieldHalfHeight }
-
- type
- CFSDirFieldPane = object(CPane)
-
- fBankStable, fAOAStable: Boolean;
-
- oldBank, oldAOA: Real;
- currBank, currAOA: Real;
-
- procedure IFSDirFieldPane (anEnclosure: CView; aSupervisor: CBureaucrat; aWidth, aHeight, aHEncl, aVEncl: integer; aHSizing, aVSizing: SizingOption);
-
- procedure Draw (var area: Rect);
- override;
-
- procedure SetBankStability (fStable: Boolean);
-
- procedure SetAOAStability (fStable: Boolean);
-
- procedure GetDirection (aBank, aAOA: Real; var aBankRate, aAOARate: Real);
-
- procedure GetCurrPosition (var aCurrBank, aCurrAOA: Real);
-
- procedure SetCurrPosition (aCurrBank, aCurrAOA: Real);
-
- procedure UpdatePosition (aBankChange, aAOAChange: Real);
-
- end;
-
-
- {***}
- { * CFSStickPane}
- { *}
- { * Pane class for the "joystick".}
- { *}
- { ***}
-
- const
- kStickHalfWidth = 16;
- kStickHalfHeight = 16;
-
- type
- StickHorRange = -kStickHalfWidth..kStickHalfWidth;
- StickVerRange = -kStickHalfHeight..kStickHalfHeight;
-
- type
- CFSStickPane = object(CPane)
-
- stickh: StickHorRange;
- stickv: StickVerRange;
-
- { On each update loop, compare the current mouse }
- { position with the position on the previous iteration. }
- { The offset is the control. }
- oldMousePt: Point;
-
- procedure IFSStickPane (anEnclosure: CView; aSupervisor: CBureaucrat; aWidth, aHeight, aHEncl, aVEncl: integer; aHSizing, aVSizing: SizingOption);
-
- procedure Draw (var area: Rect);
- override;
-
- procedure InitOldMousePt;
-
- procedure GetControl (var aBankChange, aAOAChange: Real);
- { GetControl is the responsibility of CFSStickPane }
- { so that we can also update the drawing arrow. }
- { We are able to impose a natural limit on how far }
- { we can push the stick, namely StickHorRange and }
- { StickVerRange. }
-
- procedure CentreStick;
-
- end;
-
-
- implementation
-
- end. { FSIntf }