STINGER2.PAS 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {$M 65520, 262000, 655360}
  2. Uses Objects2,Graph;
  3. Procedure EGAVGADriver;external;
  4. Function KeyPressed:boolean;assembler;
  5. asm
  6. mov ah, 1
  7. int 16h
  8. mov al, 0
  9. jz @@2
  10. mov al, 1
  11. @@2:
  12. end;{KeyPressed}
  13. {----------------------}
  14. Function ReadKey:char;assembler;
  15. asm
  16. mov ah, 00
  17. int 16h
  18. cmp al, 0
  19. jnz @@1
  20. mov al, ah
  21. @@1:
  22. end;
  23. {ReadKey}
  24. var
  25. Wrld : PWorld;
  26. Timer : LongInt Absolute $0040:$006c;
  27. BegMem,MinMem : LongInt;
  28. Last,i,Beg : Longint;
  29. MyRAH : pRAH;
  30. MyStinger : pSting;
  31. MyExpl : pExpl;
  32. mP : TParams;
  33. Page : byte;
  34. gD,gM : integer;
  35. Key : char;
  36. begin
  37. BegMem := MaxAvail;MinMem := BegMem;
  38. TIME_FACTOR := 0.2;
  39. FPS := 1;
  40. FIELD_X := 600;
  41. GLOB_G := 0.1;
  42. Randomize;
  43. {$L EGAVGA.OBJ}
  44. RegisterBGIDriver(@EGAVGADriver);
  45. Gd:=VGA;
  46. Gm:=VGAMed;
  47. INitGraph(gD,gM,'');
  48. SIZE_Y := 350;
  49. New(Wrld,Init('BG2.dat'));
  50. Wrld^.Message('Move, rotate stinger with keys, change dAngle with Del/PgDown',1,Red);
  51. With mP do begin
  52. Pos.x:=75.0;
  53. Pos.y := 300.0;
  54. Speed.X := 5.0;
  55. Speed.Y := 0.0;
  56. Accel.X := 0.0;
  57. Accel.Y := 0.0;
  58. end;
  59. New(MyRAH,Init('rah-66-2.dat',mP,100));
  60. with MyRah^ do
  61. begin
  62. CountBase := 2;
  63. countVar := 2;
  64. SpeedBase:=10;
  65. SpeedVar := 3;
  66. TrapBase := 60;
  67. TrapVar := 10;
  68. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  69. end;
  70. Wrld^.AddObject(MyRAH);
  71. {
  72. With mP do begin
  73. Pos.x:=75.0;
  74. Pos.y := 200.0;
  75. Speed.X := 7.0;
  76. Speed.Y := 0.0;
  77. Accel.X := 0.0;
  78. Accel.Y := 0.0;
  79. end;
  80. New(MyRAH,Init('rah-66-2.dat',mP,105));
  81. with MyRah^ do
  82. begin
  83. CountBase := 5;
  84. countVar := 2;
  85. SpeedBase:=10;
  86. SpeedVar := 3;
  87. TrapBase := 30;
  88. TrapVar := 10;
  89. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  90. end;
  91. Wrld^.AddObject(MyRAH);
  92. }
  93. With mP do begin
  94. Pos.x:=520.0;
  95. Pos.y := 60.0;
  96. Speed.X := 10;
  97. Speed.Y := 0;
  98. Accel.X := 0.0;
  99. Accel.Y := 0.0;
  100. end;
  101. New(MyStinger,Init('stinger.dat',mP,10,110));
  102. Wrld^.AddObject(MyStinger);
  103. MyStinger^.ChangeAngle(90);
  104. Last := timeR;
  105. i:=0;
  106. page:=0;
  107. SetActivePage(0);
  108. Wrld^.Draw;
  109. SetActivePage(1);
  110. Wrld^.Draw;
  111. while not (Key = #27) do
  112. begin
  113. if MaxAvail < MinMem then MinMem := maxAvail;
  114. Key := #0;
  115. if KeyPressed then Key:=ReadKey;
  116. case key of
  117. #80: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  118. MyStinger^.ChangeAngle(MyStinger^.Angle-1);
  119. #72: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  120. MyStinger^.ChangeAngle(MyStinger^.Angle+1);
  121. #75: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  122. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x-1;
  123. if MyStinger^.Params.Pos.X < (MyStinger^.xsize^[0] shr 1) then
  124. MyStinger^.Params.Pos.x :=MyStinger^.xsize^[0] shr 1;
  125. end;
  126. #77: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  127. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x+1;
  128. if MyStinger^.Params.Pos.X > (FIELD_X-MyStinger^.xsize^[0] shr 1) then
  129. MyStinger^.Params.Pos.x :=(FIELD_X-MyStinger^.xsize^[0] shr 1)
  130. end;
  131. #13: begin
  132. if MyStinger^.ObjType <> 'Stinger' then Key:=#27;
  133. if not MyRAH^.Started then
  134. begin
  135. Wrld^.StartObjects('RAH-66');
  136. i:=0;
  137. Beg:=timer;
  138. end
  139. else if not MyStinger^.Started then
  140. begin
  141. Wrld^.StartObjects('Stinger');
  142. Wrld^.Message('',1,0);
  143. end;
  144. end;
  145. #81: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  146. Dec(MyStinger^.dAngle);
  147. if MyStinger^.dAngle < 2 then MyStinger^.dAngle := 1;
  148. end;
  149. #83: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  150. Inc(MyStinger^.dAngle);
  151. if MyStinger^.dAngle > 180 then MyStinger^.dAngle := 180;
  152. end;
  153. end;
  154. if (MyRah^.Started or MyStinger^.Started or (Key<>#0)) then
  155. begin
  156. Inc(i);
  157. SetActivePage(Page);
  158. Wrld^.Draw;
  159. repeat until (Port[$03DA] and 8) <> 8;
  160. repeat until (Port[$03DA] and 8) = 8;
  161. SetVisualPage(Page);
  162. Page:=1-Page;
  163. end;
  164. if (MyRah^.Started or MyStinger^.Started) then
  165. begin
  166. repeat until (Timer-Last) <> 0;
  167. Wrld^.Frame(Timer-Last);
  168. end;
  169. Last := timeR;
  170. end;
  171. Beg:=Timer-Beg;
  172. Dispose(Wrld,Done);
  173. CloseGraph;
  174. if MaxAvail <> BegMem then WriteLn('Suxx, losing memory: ', BegMem-MaxAvail);
  175. WriteLn('MaxMemory - ', BegMem - MinMem);
  176. WriteLn('Average FPS - ', i/(Beg*0.055):0:4);
  177. end.