home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-05 | 1.8 KB | 83 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { sBouncer.p }
- {}
- { Sprite for the bouncer. Based on ZScrolly from the SAT demos. }
- {}
- { Copyright © 1996 by Patrick C Hew. All rights reserved. }
- {}
- {****************************************************}
-
-
- unit sBouncer;
-
- interface
-
- uses
- SAT, BDGlobals;
-
- { When the bouncer hits the edge of the SAT domain , it reverses course . }
- procedure HandleBouncer (me: SpritePtr);
-
- { A single face and set of behaviour. }
- procedure SetupBouncer (me: SpritePtr);
-
- implementation
-
- const
- zpeedH = 1;
- zpeedV = 1;
-
-
- {****************************************************}
- {}
- { HandleBouncer }
- {}
- { When the bouncer hits the edge of the SAT domain, it reverses course. }
- {}
- {****************************************************}
-
- procedure HandleBouncer (me: SpritePtr);
-
- begin { HandleBouncer }
- with me^ do begin
- position.h := position.h + speed.h;
- position.v := position.v + speed.v;
- if position.h + 32 > gSAT.offSizeH then begin
- speed.h := -zpeedH;
- end; { if }
- if position.h < 0 then begin
- speed.h := zpeedH;
- end; { if }
- if position.v + 32 > gSAT.offSizeV then begin
- speed.v := -zpeedV;
- end; { if }
- if position.v < 0 then begin
- speed.v := zpeedV;
- end; { if }
- end; { with }
- end; { HandleBouncer }
-
-
- {****************************************************}
- {}
- { SetupBouncer }
- {}
- { A single face and set of behaviour. }
- {}
- {****************************************************}
-
- procedure SetupBouncer (me: SpritePtr);
-
- begin { SetupBouncer }
- me^.task := @HandleBouncer;
- me^.face := SATGetFace(128);
- me^.kind := kindBouncer;
- SetRect(me^.hotRect, 0, 0, 32, 32);
-
- me^.speed.h := zpeedH;
- me^.speed.v := -zpeedV;
- end; { SetupBouncer }
-
-
- end. { sBouncer }