home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-08 | 4.9 KB | 222 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { CBDDirector.p }
- {}
- { Director class the BD application. }
- {}
- { Copyright © 1995 by Patrick C Hew. All rights reserved. }
- {}
- {****************************************************}
-
-
- unit CBDDirector;
-
- interface
-
- uses
- TCL, BDIntf;
-
- implementation
-
-
- {****************************************************}
- {}
- { IBDDirector }
- {}
- { Initialize an BD Director object. }
- {}
- {****************************************************}
-
- procedure CBDDirector.IBDDirector (aSupervisor: CGameApp);
-
-
- begin { IBDDirector }
- ISATDirector(aSupervisor);
-
- itsGameApp := aSupervisor;
-
- BuildWindow;
- SetUpSprites;
- GetWindow.Select;
- end; { IBDDirector }
-
-
- {****************************************************}
- {}
- { Free }
- {}
- { We reset our private pointer to the application. }
- {}
- {****************************************************}
-
- procedure CBDDirector.Free;
-
- begin { Free }
- itsGameApp := nil;
-
- inherited Free;
- end; { Free }
-
-
- {****************************************************}
- {}
- { BuildWindow }
- {}
- { We build a fixed size window which has one pane, the SAT pane. }
- {}
- {****************************************************}
-
- procedure CBDDirector.BuildWindow;
-
- const
- kSATPanoLenh = 400;
- kSATPanoLenv = 280;
-
- var
- theWindow: CSATWindow;
- theRect: Rect;
- theSATPane: CSATPane;
- theScrollPane: CScrollPane;
-
- begin { BuildWindow }
- { There is a bug, probably in this method, which makes window zooming produce strange results. }
-
- new(theWindow);
- theWindow.ISATWindow(WINDBD, kNotFloating, gDesktop, SELF);
- itsWindow := theWindow;
-
- NEW(theScrollPane);
- theScrollPane.IScrollPane(itsWindow, SELF, 10, 10, 0, 0, sizELASTIC, sizELASTIC, kHasHScroll, kHasVScroll, kHasSizebox);
- theScrollPane.FitToEnclFrame(kDoHorizontal, kDoVertical);
-
- SetRect(theRect, 0, 0, kSATPanoLenh, kSATPanoLenv);
-
- new(theSATPane);
- theSATPane.ISATPane(theScrollPane, SELF, 10, 10, 0, 0, sizELASTIC, sizELASTIC, PICTColorBackground, PICTBWBackground, theRect, kNoUseMenuBar, kNoDither4Bit, kNoBeSmart);
- theSATPane.FitToEnclosure(kDoHorizontal, kDoVertical);
-
- itsSATPane := theSATPane;
- theWindow.InstallSATPane(theSATPane);
-
- theScrollPane.InstallPanorama(theSATPane);
- theScrollPane.SetSteps(8, 8);
- theScrollPane.SetOverlaps(72, 72);
-
- SetRect(theRect, 80, 80, kSATPanoLenh, kSATPanoLenv);
- itsWindow.SetSizeRect(theRect);
-
- gDecorator.PlaceNewWindow(itsWindow);
- end; { BuildWindow }
-
-
- {****************************************************}
- {}
- { SetUpSprites }
- {}
- { Set up the sprites for the bouncer. }
- {}
- {****************************************************}
-
- procedure CBDDirector.SetUpSprites;
-
- var
- theSpritePtr: SpritePtr;
-
- begin { SetUpSprites }
- theSpritePtr := SATNewSprite(0, 30, 30, @SetupBouncer);
- end; { SetUpSprites }
-
-
- {****************************************************}
- {}
- { UpdateMenus }
- {}
- { Enables the appropriate commands in the Game Menu. }
- {}
- {****************************************************}
-
- procedure CBDDirector.UpdateMenus;
-
- begin { UpdateMenus }
- inherited UpdateMenus;
-
- if isPlaying then begin
- gBartender.EnableCmd(cmdAbort);
- if isPaused then begin
- gBartender.EnableCmd(cmdResume);
- end { if }
- else begin
- gBartender.EnableCmd(cmdPause);
- end { else }
- end { if }
- else begin
- gBartender.EnableCmd(cmdStart);
- end; { else }
- end; { UpdateMenus }
-
-
- {****************************************************}
- {}
- { DoCommand }
- {}
- { React to commands to start, pause, resume or abort the game. }
- {}
- {****************************************************}
-
- procedure CBDDirector.DoCommand (theCommand: longint);
-
- begin { DoCommand }
- case theCommand of
-
- cmdStart: begin
- isPlaying := TRUE;
- isPaused := FALSE;
- itsGameApp.BeginGameMode;
- end; { cmdStart }
-
- cmdPause: begin
- isPaused := TRUE;
- itsGameApp.EndGameMode;
- end; { cmdPause }
-
- cmdResume: begin
- isPaused := FALSE;
- itsGameApp.BeginGameMode;
- end; { cmdPause }
-
- cmdAbort: begin
- isPlaying := FALSE;
- isPaused := FALSE;
- itsGameApp.EndGameMode;
- end;
-
- otherwise begin
- inherited DoCommand(theCommand);
- end; { otherwise }
- end; { case }
- end; { DoCommand }
-
-
- {****************************************************}
- {}
- { Dawdle }
- {}
- { When playing, this is the heart of the game loop. }
- {}
- {****************************************************}
-
- procedure CBDDirector.Dawdle (var maxSleep: longint);
-
- begin { DoPlay }
- if isPlaying and not isPaused then begin
-
- maxSleep := 0;
-
- itsSATPane.DoSATRun2(FALSE);
-
- { Maybe a delay loop here, if you want to slow things down. }
- end; { if }
- end; { Dawdle }
-
-
- end. { CBDDirector }