UCadencer.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. unit UCadencer;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs,Unit1,GLKeyboard, GLScene, GLCadencer;
  6. type
  7. TForm4 = class(TForm)
  8. GLCadencer1: TGLCadencer;
  9. procedure FormDestroy(Sender: TObject);
  10. procedure GLCadencer1Progress(Sender: TObject; const deltaTime,
  11. newTime: Double);
  12. function Jumpheight(ID:Integer):Real;
  13. function Jumpstrength(Speed:Real):Real;
  14. procedure ShowPlayers(const deltatime:double);
  15. procedure ShowNPC(const deltatime:double);
  16. procedure MovePlayer(const deltatime:double);
  17. procedure ModifyThrust(const deltatime:double);
  18. procedure UpdateSpeed;
  19. private
  20. { Private declarations }
  21. public
  22. { Public declarations }
  23. end;
  24. var
  25. Form4: TForm4;
  26. maxJumpHeight:Real; //4-PlayerHeight[false]
  27. MoveDirX,MoveDirZ:Real;
  28. Lastjumptime:Real=0;
  29. LastPos:Integer;
  30. CameraDirection:Integer;
  31. implementation
  32. uses UColorByID,Math,UMoveToRoom,GLHUDObjects,UMYUtils;
  33. {$R *.dfm}
  34. procedure TForm4.GLCadencer1Progress(Sender: TObject; const deltaTime,
  35. newTime: Double);
  36. begin
  37. ModifyThrust(deltaTime); //0 ms
  38. if (not IsKeyDown(32))
  39. and (not Players[MyID].jumping) then
  40. jumppressed:=false;
  41. if inMenu or Lost then begin
  42. Camera.Turn(20*deltatime);
  43. end;
  44. MovePlayer(deltaTime); //0,0668ms
  45. Camera.Position.Y:=Jumpheight(MyID); //0,0003ms
  46. if players[MyId].CeilWalk then
  47. Camera.Position.Y:=-Camera.Position.Y+2;
  48. Players[MyID].X:=Camera.Position.X+PosX*20;
  49. Players[MyID].Z:=Camera.Position.Z+PosZ*20;
  50. ShowPlayers(deltaTime); //0,0025ms
  51. // if FrameCount>3 then
  52. // SW.ResetTimer;
  53. // for C1:=1 to 1000000 do begin
  54. ShowNPC(deltaTime); //0,0024ms
  55. // if FrameCount<=3 then Break;
  56. // end;
  57. // if FrameCount>3 then
  58. // showmessage(inttostr(SW.TimeElapsedmilliSecs));
  59. Inc(FrameCount);
  60. end;
  61. procedure TForm4.ShowNPC(const deltatime:double);
  62. var C1,C2:Integer;
  63. begin
  64. for C1:=-RaumRange to RaumRange do
  65. for C2:=-RaumRange to RaumRange do
  66. if MuhNPCArr[C1,C2].Body.Visible then begin
  67. MuhNPCArr[C1,C2].Body.Position.X:=
  68. MuhNPCArr[C1,C2].Body.Position.X+
  69. MuhNPCArr[C1,C2].MoveX;
  70. if MuhNPCArr[C1,C2].Body.Position.X>8.5+20*C1 then begin
  71. MuhNPCArr[C1,C2].Body.Position.X:=8.5+20*C1
  72. -(MuhNPCArr[C1,C2].Body.Position.X-(8.5+20*C1));
  73. MuhNPCArr[C1,C2].MoveX:=-MuhNPCArr[C1,C2].MoveX;
  74. end;
  75. if MuhNPCArr[C1,C2].Body.Position.X<-8.5+20*C1 then begin
  76. MuhNPCArr[C1,C2].Body.Position.X:=-8.5+20*C1
  77. +((-8.5+20*C1)-MuhNPCArr[C1,C2].Body.Position.X);
  78. MuhNPCArr[C1,C2].MoveX:=-MuhNPCArr[C1,C2].MoveX;
  79. end;
  80. MuhNPCArr[C1,C2].Body.Position.Y:=
  81. MuhNPCArr[C1,C2].Body.Position.Y+
  82. MuhNPCArr[C1,C2].MoveY;
  83. if MuhNPCArr[C1,C2].Body.Position.Y>3 then begin
  84. MuhNPCArr[C1,C2].Body.Position.Y:=3
  85. -(MuhNPCArr[C1,C2].Body.Position.Y-3);
  86. MuhNPCArr[C1,C2].MoveY:=-MuhNPCArr[C1,C2].MoveY;
  87. end;
  88. if MuhNPCArr[C1,C2].Body.Position.Y<-1 then begin
  89. MuhNPCArr[C1,C2].Body.Position.Y:=-1
  90. +(-1-MuhNPCArr[C1,C2].Body.Position.Y);
  91. MuhNPCArr[C1,C2].MoveY:=-MuhNPCArr[C1,C2].MoveY;
  92. end;
  93. MuhNPCArr[C1,C2].Body.Position.Z:=
  94. MuhNPCArr[C1,C2].Body.Position.Z+
  95. MuhNPCArr[C1,C2].MoveZ;
  96. if MuhNPCArr[C1,C2].Body.Position.Z>8.5+20*C2 then begin
  97. MuhNPCArr[C1,C2].Body.Position.Z:=8.5+20*C2
  98. -(MuhNPCArr[C1,C2].Body.Position.Z-(8.5+20*C2));
  99. MuhNPCArr[C1,C2].MoveZ:=-MuhNPCArr[C1,C2].MoveZ;
  100. end;
  101. if MuhNPCArr[C1,C2].Body.Position.Z<-8.5+20*C2 then begin
  102. MuhNPCArr[C1,C2].Body.Position.Z:=-8.5+20*C2
  103. +((-8.5+20*C2)-MuhNPCArr[C1,C2].Body.Position.Z);
  104. MuhNPCArr[C1,C2].MoveZ:=-MuhNPCArr[C1,C2].MoveZ;
  105. end;
  106. end;
  107. end;
  108. function TForm4.Jumpstrength(Speed:Real):Real;
  109. begin
  110. if Speed<=15 then
  111. Result:=-7/180*sqr(Players[MyID].Speed)+Players[MyID].Speed*1.15
  112. else Result:=Speed*0.6;
  113. end;
  114. function TForm4.Jumpheight(ID:Integer):Real;
  115. var JumpStrenghtByID:Real; RT:PRoomtype;
  116. begin
  117. JumpStrenghtByID:=Jumpstrength(Players[ID].Speed);
  118. if (Players[ID].Speed<=0)
  119. or (Players[ID].jumptime<-0.00001) then begin
  120. Players[ID].jumping:=false;
  121. Result:=-2+PlayerDepth[false];
  122. Exit;
  123. end;
  124. Result:=
  125. -4.905*sqr(Players[ID].jumptime)
  126. +JumpStrenghtByID*Players[ID].jumptime
  127. -2+PlayerDepth[false];
  128. RT:=GetRT(Round(Players[ID].X/20),Round(Players[ID].Z/20));
  129. if (Result>maxJumpHeight) and not Won then begin
  130. if
  131. ((RT.MaterialName[Up]='Open') and not Players[ID].Ceilwalk)
  132. or
  133. ((RT.MaterialName[Down]='Open') and Players[ID].Ceilwalk) then
  134. Players[ID].OutOfMaze:=true;
  135. if not Players[ID].OutOfMaze then begin
  136. Players[ID].jumptime:=Players[ID].jumptime+
  137. (200*sqrt(
  138. sqr(JumpStrenghtByID)+(981*(-2+PlayerDepth[false]))
  139. /50-(981*maxJumpHeight)/50))
  140. /981;
  141. Result:=
  142. -4.905*sqr(Players[ID].jumptime)
  143. +JumpStrenghtByID*Players[ID].jumptime
  144. -2+PlayerDepth[false];
  145. end;
  146. end;
  147. if not Players[ID].OutOfMaze and (Result<-2+PlayerDepth[false]) then begin
  148. if
  149. ((RT.MaterialName[Down]='Open') and not Players[ID].Ceilwalk)
  150. or
  151. ((RT.MaterialName[Up]='Open') and Players[ID].Ceilwalk) then begin
  152. Players[ID].OutOfMaze:=true;
  153. end else begin
  154. Players[ID].jumping:=false;
  155. Result:=-2+PlayerDepth[false];
  156. end;
  157. end;
  158. Players[ID].OutOfMaze:=
  159. (Result<-2.001+PlayerDepth[false])
  160. or (Result>4.001-PlayerHeight[false]);
  161. if Result>200 then Result:=200;
  162. if Result<-200 then Result:=200;
  163. end;
  164. procedure TForm4.FormDestroy(Sender: TObject);
  165. begin
  166. GLCadencer1.Enabled:=false;
  167. end;
  168. procedure TForm4.MovePlayer(const deltatime:double);
  169. var R1:Real; MinY,MaxY:Real;
  170. begin
  171. if not Lost then begin
  172. Form1.GLUserInterface1.MouseUpdate;
  173. Form1.GLUserInterface1.MouseLook;
  174. if Ceil(Camera.Direction.X)+2*Ceil(Camera.Direction.Z)
  175. <>CameraDirection then
  176. Form1.Reload;
  177. end;
  178. if not Players[MyID].jumping then begin
  179. MoveDirX:=Camera.Position.X;
  180. MoveDirZ:=Camera.Position.Z;
  181. if isKeyDown('w') then begin
  182. if not (isKeyDown('d'))
  183. and not (isKeyDown('a'))
  184. then R1:=Players[MyID].Speed else R1:=Players[MyID].Speed/sqrt(2);
  185. end else
  186. if isKeyDown('a') then begin
  187. if not (isKeyDown('w'))
  188. and not (isKeyDown('s'))
  189. then R1:=Players[MyID].Speed else R1:=Players[MyID].Speed/sqrt(2);
  190. end else
  191. if isKeyDown('s') then begin
  192. if not (isKeyDown('d'))
  193. and not (isKeyDown('a'))
  194. then R1:=Players[MyID].Speed else R1:=Players[MyID].Speed/sqrt(2);
  195. end else
  196. if isKeyDown('d') then begin
  197. if not (isKeyDown('w'))
  198. and not (isKeyDown('s'))
  199. then R1:=Players[MyID].Speed else R1:=Players[MyID].Speed/sqrt(2);
  200. end else R1:=0;
  201. if not inMenu and not Lost and
  202. not GetRT(PosX,PosZ).PushPlayer[THeight(Players[MyID].Ceilwalk)] then begin
  203. if isKeyDown('w') then Camera.Move(R1*deltatime);
  204. if isKeyDown('s') then Camera.Move(-R1*deltatime);
  205. if isKeyDown('d') then Camera.Slide(R1*deltatime);
  206. if isKeyDown('a') then Camera.Slide(-R1*deltatime);
  207. end;
  208. if GetRT(PosX,PosZ).PushPlayer[THeight(Players[MyID].Ceilwalk)] and
  209. assigned(Map[PosX,PosZ].Inhalt.Daten) then begin
  210. case TRichtung(Map[PosX,PosZ].Inhalt.Daten^) of
  211. px:Camera.Position.X:=Camera.Position.X+deltaTime*30;
  212. nx:Camera.Position.X:=Camera.Position.X-deltatime*30;
  213. pz:Camera.Position.Z:=Camera.Position.Z+deltatime*30;
  214. nz:Camera.Position.Z:=Camera.Position.Z-deltatime*30;
  215. end;
  216. if not
  217. (isKeyDown('w')
  218. or isKeyDown('s')
  219. or isKeyDown('d')
  220. or isKeyDown('a')) then
  221. if (
  222. ((TRichtung(Map[PosX,PosZ].Inhalt.Daten^)=px)
  223. and GetRT(PosX+1,PosZ).PushPlayer[THeight(Players[MyID].Ceilwalk)]
  224. and (TRichtung(Map[PosX+1,PosZ].Inhalt.Daten^)=nx))
  225. or ((TRichtung(Map[PosX,PosZ].Inhalt.Daten^)=nx)
  226. and GetRT(PosX-1,PosZ).PushPlayer[THeight(Players[MyID].Ceilwalk)]
  227. and (TRichtung(Map[PosX-1,PosZ].Inhalt.Daten^)=px))
  228. or ((TRichtung(Map[PosX,PosZ].Inhalt.Daten^)=nz)
  229. and GetRT(PosX,PosZ-1).PushPlayer[THeight(Players[MyID].Ceilwalk)]
  230. and (TRichtung(Map[PosX,PosZ-1].Inhalt.Daten^)=pz))
  231. or ((TRichtung(Map[PosX,PosZ].Inhalt.Daten^)=pz)
  232. and GetRT(PosX,PosZ+1).PushPlayer[THeight(Players[MyID].Ceilwalk)]
  233. and (TRichtung(Map[PosX,PosZ+1].Inhalt.Daten^)=nz))
  234. ) then
  235. case TRichtung(Map[PosX,PosZ].Inhalt.Daten^) of
  236. px:Camera.Position.X:=Min(Camera.Position.X+deltaTime,9.99);
  237. nx:Camera.Position.X:=Max(Camera.Position.X-deltatime,-9.99);
  238. pz:Camera.Position.Z:=Min(Camera.Position.Z+deltatime,9.99);
  239. nz:Camera.Position.Z:=Max(Camera.Position.Z-deltatime,-9.99);
  240. end;
  241. end;
  242. end else begin
  243. Camera.Position.X:=Camera.Position.X+2*MoveDirX*deltatime;
  244. Camera.Position.Z:=Camera.Position.Z+2*MoveDirZ*deltatime;
  245. end;
  246. MinY:=Camera.Position.Y-PlayerDepth[players[MyId].CeilWalk];
  247. MaxY:=Camera.Position.Y+PlayerHeight[players[MyId].CeilWalk];
  248. if ((MaxY<4) and (MaxY>-2))
  249. or ((MinY<4) and (MinY>-2)) then begin
  250. if (Camera.Position.X>8.5)
  251. and (px in Map[posX,PosZ].Walls) then begin
  252. Camera.Position.X:=8.5;
  253. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  254. end;
  255. if (Camera.Position.Z>8.5)
  256. and (pz in Map[posX,PosZ].Walls) then begin
  257. Camera.Position.Z:=8.5;
  258. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  259. end;
  260. if (Camera.Position.X<-8.5)
  261. and (nx in Map[posX,PosZ].Walls) then begin
  262. Camera.Position.X:=-8.5;
  263. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  264. end;
  265. if (Camera.Position.Z<-8.5)
  266. and (nz in Map[posX,PosZ].Walls) then begin
  267. Camera.Position.Z:=-8.5;
  268. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  269. end;
  270. end;
  271. if ((MaxY<1) and (MaxY>-2))
  272. or ((MinY<1) and (MinY>-2)) then begin
  273. if (Camera.Position.X>8.5)
  274. and (px in Map[posX,PosZ].DownWalls) then begin
  275. Camera.Position.X:=8.5;
  276. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  277. end;
  278. if (Camera.Position.X<-8.5)
  279. and (nx in Map[posX,PosZ].DownWalls) then begin
  280. Camera.Position.X:=-8.5;
  281. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  282. end;
  283. if (Camera.Position.Z>8.5)
  284. and (pz in Map[posX,PosZ].DownWalls) then begin
  285. Camera.Position.Z:=8.5;
  286. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  287. end;
  288. if (Camera.Position.Z<-8.5)
  289. and (nz in Map[posX,PosZ].DownWalls) then begin
  290. Camera.Position.Z:=-8.5;
  291. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  292. end;
  293. end;
  294. if ((MaxY<4) and (MaxY>1))
  295. or ((MinY<4) and (MinY>1)) then begin
  296. if (Camera.Position.X>8.5)
  297. and (px in Map[posX,PosZ].UpWalls) then begin
  298. Camera.Position.X:=8.5;
  299. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  300. end;
  301. if (Camera.Position.X<-8.5)
  302. and (nx in Map[posX,PosZ].UpWalls) then begin
  303. Camera.Position.X:=-8.5;
  304. if Players[Myid].jumping then MoveDirX:=-MoveDirX;
  305. end;
  306. if (Camera.Position.Z>8.5)
  307. and (pz in Map[posX,PosZ].UpWalls) then begin
  308. Camera.Position.Z:=8.5;
  309. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  310. end;
  311. if (Camera.Position.Z<-8.5)
  312. and (nz in Map[posX,PosZ].UpWalls) then begin
  313. Camera.Position.Z:=-8.5;
  314. if Players[Myid].jumping then MoveDirZ:=-MoveDirZ;
  315. end;
  316. end;
  317. if not Players[Myid].jumping then begin
  318. MoveDirX:=(Camera.Position.X-MoveDirX)/deltatime;
  319. MoveDirZ:=(Camera.Position.Z-MoveDirZ)/deltatime;
  320. end;
  321. repeat
  322. if Camera.Position.X>10 then begin
  323. Camera.Position.X:=Camera.Position.X-20;
  324. Inc(PosX);
  325. MoveToRoom(PosX-1,PosZ);
  326. end;
  327. if Camera.Position.Z>10 then begin
  328. Camera.Position.Z:=Camera.Position.Z-20;
  329. Inc(Posz);
  330. MoveToRoom(PosX,PosZ-1);
  331. end;
  332. if Camera.Position.X<-10 then begin
  333. Camera.Position.X:=Camera.Position.X+20;
  334. Dec(PosX);
  335. MoveToRoom(PosX+1,PosZ);
  336. end;
  337. if Camera.Position.Z<-10 then begin
  338. Camera.Position.Z:=Camera.Position.Z+20;
  339. Dec(Posz);
  340. MoveToRoom(PosX,PosZ+1);
  341. end;
  342. until (Camera.Position.X<=10)
  343. and (Camera.Position.Z<=10)
  344. and (Camera.Position.X>=-10)
  345. and (Camera.Position.Z>=-10);
  346. end;
  347. procedure TForm4.ShowPlayers(const deltatime:double);
  348. var C2:Integer; R,G,B:Real;
  349. begin
  350. for C2:=0 to High(playerarr) do begin
  351. Players[C2].jumptime:=Players[C2].jumptime+deltatime;
  352. if Cardinal(C2)<>MyID then begin
  353. if Players[C2].LastTimeEnd-Players[C2].LastTimeStart<>0 then
  354. playerarr[C2].Position.X:=Players[C2].LastX
  355. +(GetTickCount-Players[C2].LastTimeStart)
  356. /(Players[C2].LastTimeEnd-Players[C2].LastTimeStart)
  357. *(Players[C2].X-Players[C2].LastX);
  358. if Gettickcount>Players[C2].LastTimeEnd then
  359. playerarr[C2].Position.X:=Players[C2].X;
  360. playerarr[C2].Position.X:=playerarr[C2].Position.X-PosX*20;
  361. if players[C2].jumping then Players[C2].Y:=Jumpheight(C2)
  362. else Players[C2].Y:=-2+PlayerDepth[false];
  363. if players[C2].CeilWalk then
  364. Players[C2].Y:=-Players[C2].Y+2;
  365. Players[C2].Y:=Players[C2].Y
  366. -PlayerDepth[Players[C2].CeilWalk]
  367. +(PlayerDepth[Players[C2].CeilWalk]
  368. +PlayerHeight[Players[C2].CeilWalk])/2;
  369. playerarr[C2].Position.Y:=Players[C2].Y;
  370. if Players[C2].LastTimeEnd-Players[C2].LastTimeStart<>0 then
  371. playerarr[C2].Position.Z:=Players[C2].LastZ
  372. +(GetTickCount-Players[C2].LastTimeStart)
  373. /(Players[C2].LastTimeEnd-Players[C2].LastTimeStart)
  374. *(Players[C2].Z-Players[C2].LastZ);
  375. if Gettickcount>Players[C2].LastTimeEnd then
  376. playerarr[C2].Position.Z:=Players[C2].Z;
  377. playerarr[C2].Position.Z:=playerarr[C2].Position.Z-PosZ*20;
  378. if C2>High(PlayerGoalDistPanels) then
  379. Setlength(PlayerGoalDistPanels,C2+1);
  380. if not assigned(PlayerGoalDistPanels[C2]) then begin
  381. PlayerGoalDistPanels[C2]:=
  382. TGLHUDText(Form1.PlayerGoalDists.AddNewChild(TGLHUDText));
  383. PlayerGoalDistPanels[C2].BitmapFont:=Form1.PlayerGoalDistFont;
  384. RedbyID(C2,R);
  385. GreenbyID(C2,G);
  386. BluebyID(C2,B);
  387. PlayerGoalDistPanels[C2].ModulateColor.SetColor(R,G,B);
  388. PlayerGoalDistPanels[C2].Position.SetPoint
  389. (0.01*self.Width,Form1.PlayerGoalDistFont.Font.Size*(C2+0.5),0);
  390. end;
  391. PlayerGoalDistPanels[C2].Text:=
  392. 'P'+IntToStr(C2)+': '
  393. +FloatToStr(Round(10*sqrt
  394. (sqr(GoalPos.X*20-(playerarr[C2].Position.X+PosX*20))
  395. +sqr(GoalPos.Y*20-(playerarr[C2].Position.Z+PosZ*20))))/10);
  396. Playerarr[C2].Visible:=
  397. ((RaumRange+1)*20>Playerarr[C2].Position.X)
  398. and ((RaumRange+1)*20>Playerarr[C2].Position.Z)
  399. and ((-RaumRange-1)*20<Playerarr[C2].Position.X)
  400. and ((-RaumRange-1)*20<Playerarr[C2].Position.Z);
  401. end else begin //mit C2=MYID durchführen
  402. if not Lost then
  403. Players[MyID].Dead:=false;
  404. playerarr[C2].Position.SetPoint(Camera.Position.DirectVector);
  405. if C2>High(PlayerGoalDistPanels) then
  406. Setlength(PlayerGoalDistPanels,C2+1);
  407. if not assigned(PlayerGoalDistPanels[C2]) then begin
  408. PlayerGoalDistPanels[C2]:=
  409. TGLHUDText(Form1.PlayerGoalDists.AddNewChild(TGLHUDText));
  410. PlayerGoalDistPanels[C2].BitmapFont:=Form1.PlayerGoalDistFont;
  411. RedbyID(C2,R);
  412. GreenbyID(C2,G);
  413. BluebyID(C2,B);
  414. PlayerGoalDistPanels[C2].ModulateColor.SetColor(R,G,B);
  415. PlayerGoalDistPanels[C2].Position.SetPoint
  416. (0.01*self.Width,Form1.PlayerGoalDistFont.Font.Size*(C2+0.5),0);
  417. end;
  418. PlayerGoalDistPanels[C2].Text:=
  419. 'Your ID: '+IntToStr(C2);
  420. Playerarr[C2].Visible:=false;
  421. Players[MyID].Y:=Camera.Position.Y
  422. -PlayerDepth[Players[MyID].CeilWalk]
  423. +(PlayerDepth[Players[MyID].CeilWalk]
  424. +PlayerHeight[Players[MyID].CeilWalk])/2;
  425. end;
  426. if Playerarr[C2].Position.X>(mapsize+10)*20 then
  427. Playerarr[C2].Position.X:=0;
  428. if Playerarr[C2].Position.Z>(mapsize+10)*20 then
  429. Playerarr[C2].Position.Z:=0;
  430. if Playerarr[C2].Position.X<-(mapsize+10)*20 then
  431. Playerarr[C2].Position.X:=0;
  432. if Playerarr[C2].Position.Z<-(mapsize+10)*20 then
  433. Playerarr[C2].Position.Z:=0;
  434. end;
  435. end;
  436. procedure TForm4.ModifyThrust(const deltatime:double);
  437. begin
  438. if Lost or inMenu then Exit;
  439. if IsKeyDown('u') then Form1.ThrustBar.Position:=
  440. Form1.ThrustBar.Position+Round(deltatime*250) else
  441. if IsKeyDown('j') then Form1.ThrustBar.Position:=
  442. Form1.ThrustBar.Position-Round(deltatime*250) else
  443. Exit;
  444. if Form1.ThrustBar.Position<5 then Form1.ThrustBar.Position:=5;
  445. UpdateSpeed;
  446. end;
  447. procedure TForm4.UpdateSpeed;
  448. begin
  449. Players[MyID].Speed:=Players[MyID].Speed*Form1.ThrustBar.Position/LastPos;
  450. Form1.GLHUDText1.Text:='Speed: '
  451. +Floattostr(Round(100*Players[MyID].Speed)/100)+' m/s';
  452. if Players[MyID].Speed<0.0001 then
  453. Form1.GLHUDText1.Text:='Speed: 0 m/s';
  454. LastPos:=Form1.ThrustBar.Position;
  455. end;
  456. end.