Unit1.pas 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, GLScene, GLObjects, GLCoordinates, GLWin32Viewer,
  6. GLCrossPlatform, GLCadencer, jpeg,
  7. GLNavigator, Math, ExtCtrls, StdCtrls, ComCtrls,
  8. GLBitmapFont, GLWindowsFont,
  9. GLGameMenu, GLHUDObjects, GLConsole, GLGui, GLWindows,
  10. typinfo, ScktComp, GLGeomObjects,UMyUtils, GLBaseClasses;
  11. type THeight=(Down,Up); //todo 1:Zeitanzeige
  12. type TInhaltSorte=(
  13. empty,Arrow,Goal,YSNP,Green,GreenTrap, //0..8
  14. WallTrap,Speed,BadSpeed,GreenSpeed,Turner,UpDownPorter,UpPorter, //9..15
  15. DownPorter,Explosion,RainbowTrap,Pusher,BlackExplosion,Lightning //16..20
  16. );
  17. type TPanelConfig=record
  18. ID:Cardinal;
  19. TopDivH,LeftDivW,HeightDivH,WidthDivW:Real;
  20. Text:String;
  21. FontColor,BackGroundColor:TColor;
  22. FontSizeDivH:Real;
  23. Seconds:Real;
  24. DontShowIfWon:Boolean;
  25. SpeedAtEnd:Boolean;
  26. end;
  27. type PPanelConfig=^TPanelConfig;
  28. type TInhalt=record
  29. Sorte:Integer;
  30. Daten:Pointer;
  31. end;
  32. type TPlayer=record
  33. X,Y,Z:Real;
  34. LastX,LastZ:Real;
  35. LastTimeStart,LastTimeEnd:Cardinal;
  36. Ceilwalk:Boolean;
  37. jumping:Boolean;
  38. jumptime:Real;
  39. Speed:Real;
  40. Dead:Boolean;
  41. OutOfMaze:Boolean;
  42. end;
  43. type TRoomtype=record
  44. MaterialName:array[THeight] of string;
  45. ID:Cardinal;
  46. Roomfrequenzy:Real;
  47. Explode:array[THeight] of Boolean;
  48. ExplodeOtherPlayer:array[THeight] of Boolean;
  49. PortTo:array[THeight] of Boolean;
  50. TurnToGoal:array[THeight] of Boolean;
  51. WinAtArrival:Boolean;
  52. YSNP:array[THeight] of Boolean;
  53. GreenWallsAround:Boolean;
  54. ChangeAtArrivalTo:array[THeight] of Integer;//-1=nicht ändern, 0=Feld leeren
  55. ChangeWallsAtArrival:Boolean;
  56. ChangeSpeedAtArrival:Real;
  57. ChangeSpeedRandom:array[THeight] of Boolean;
  58. TurnPlayer:Boolean;
  59. PortPlayerToCenter:Boolean;
  60. PushPlayer:array[THeight] of Boolean;
  61. TurnRandom:array[THeight] of Boolean;
  62. InkOthers:array[THeight] of Boolean;
  63. ChangeOtherPlayerSpeed:Boolean;
  64. Contaminate:Boolean;
  65. OPTanzGegner:Boolean;
  66. Passierbar:Boolean;
  67. NotAtSpawn:Boolean;
  68. WallCageTrap:Boolean;
  69. NotNextToSelf:Boolean;
  70. SPInvisible:Boolean; //todo 1: raus
  71. end;
  72. type PRoomtype=^TRoomtype;
  73. type PGLCube=^TGLCube;
  74. type TRichtung=(px,nx,pz,nz);
  75. type TWallset=set of TRichtung;
  76. type PWallset=^TWallset;
  77. type TRaum=record
  78. created:Boolean;
  79. Walls,UpWalls,DownWalls:TWallset;
  80. Inhalt:TInhalt;
  81. end;
  82. type PRaum=^TRaum;
  83. const mapsize=500;
  84. type TMap=array[-mapsize..mapsize,-mapsize..mapsize] of TRaum;
  85. type TMuhNPC=record //todo 2:nach Inhalt.Daten
  86. Body:TGLCube;
  87. MoveX,MoveY,MoveZ:Real;
  88. end;
  89. type
  90. TForm1 = class(TForm)
  91. Scene1: TGLScene;
  92. GLSceneViewer1: TGLSceneViewer;
  93. Panel1: TPanel;
  94. Timer1: TTimer;
  95. GLUserInterface1: TGLUserInterface;
  96. GLNavigator1: TGLNavigator;
  97. Panel2: TPanel;
  98. Panel3: TPanel;
  99. Panel4: TPanel;
  100. Panel5: TPanel;
  101. Panel6: TPanel;
  102. Panel8: TPanel;
  103. Panel9: TPanel;
  104. Panel11: TPanel;
  105. Panel13: TPanel;
  106. RichEdit1: TRichEdit;
  107. MenuFont: TGLWindowsBitmapFont;
  108. PlayerGoalDistFont: TGLWindowsBitmapFont;
  109. Memo1: TMemo;
  110. Walls: TGLDummyCube;
  111. OtherPlayers: TGLDummyCube;
  112. GLCamera1: TGLCamera;
  113. Planes: TGLDummyCube;
  114. Pushers: TGLDummyCube;
  115. UpDownPorters: TGLDummyCube;
  116. GreenSpeeds: TGLDummyCube;
  117. Explosions: TGLDummyCube;
  118. BadSpeeds: TGLDummyCube;
  119. Turners: TGLDummyCube;
  120. Grounds: TGLDummyCube;
  121. Speeds: TGLDummyCube;
  122. Arrows: TGLDummyCube;
  123. YSNPs: TGLDummyCube;
  124. Ceilings: TGLDummyCube;
  125. Blackexplosions: TGLDummyCube;
  126. Lightnings: TGLDummyCube;
  127. Menu: TGLDummyCube;
  128. MPJoinMenu: TGLGameMenu;
  129. MPHostMenu: TGLGameMenu;
  130. MPMenu: TGLGameMenu;
  131. VideoMenu: TGLGameMenu;
  132. SettingsMenu: TGLGameMenu;
  133. MainMenu: TGLGameMenu;
  134. HUDTexts: TGLDummyCube;
  135. GLHUDText1: TGLHUDText;
  136. PlayerGoalDists: TGLDummyCube;
  137. GLHUDText2: TGLHUDText;
  138. MuhNPCs: TGLDummyCube;
  139. ThrustBar: TProgressBar;
  140. PlayerLight: TGLLightSource;
  141. procedure Timer1Timer(Sender: TObject);
  142. procedure FormCreate(Sender: TObject);
  143. procedure FormDestroy(Sender: TObject);
  144. procedure FormKeyPress(Sender: TObject; var Key: Char);
  145. function NewWall(x,z:Integer; width,depth:Real):TGLCube;
  146. function NewUpWall(x,z:Integer; width,depth:Real):TGLCube;
  147. function NewDownWall(x,z:Integer; width,depth:Real):TGLCube;
  148. function NewMuhNPCBody(x,z:Integer):TGLCube;
  149. procedure startJump(ID:Integer);
  150. procedure activateWall(dir,x,z:Integer; activate:Boolean);
  151. procedure activateUpWall(dir,x,z:Integer; activate:Boolean);
  152. procedure activateDownWall(dir,x,z:Integer; activate:Boolean);
  153. procedure activateGreen(x,z:Integer; activate:Boolean);
  154. procedure Reload;
  155. procedure ReloadWallShaders;
  156. procedure ReloadTexQual;
  157. procedure CreateMap;
  158. procedure ReloadRoom(X,Z:Integer);
  159. procedure SpreadContamination(X,Z:Integer);
  160. procedure Explode(X,Z:Integer);
  161. function NewPlane(x,z:Integer; Height:THeight;
  162. Sorte:Integer):TGLPlane;
  163. function NewPlayer(ID:Integer):TGLCylinder;
  164. procedure Creategoal;
  165. procedure FormResize(Sender: TObject);
  166. procedure RearrangePanels;
  167. procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
  168. X, Y: Integer);
  169. procedure Respawn;
  170. procedure GLSceneViewer1MouseDown(Sender: TObject;
  171. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  172. procedure WinGame(ID: Cardinal);
  173. procedure LoseGame;
  174. procedure ChangeSpeedTo(NewSpeed:Real);
  175. procedure MultiplySpeedBy(Factor:Real);
  176. procedure ChangeSpeedBy(DeltaSpeed:Real);
  177. procedure ThrustBarMouseDown(Sender: TObject; Button: TMouseButton;
  178. Shift: TShiftState; X, Y: Integer);
  179. procedure GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton;
  180. Shift: TShiftState; X, Y: Integer);
  181. procedure ShowPanel(ID:Cardinal);
  182. private
  183. end;
  184. function GetRT(X,Z:Integer):PRoomtype;
  185. function GetPC(X,Z:Integer):PPanelConfig;
  186. const
  187. PlayerDepth:array[Boolean] of Real=(1.6,0.3);
  188. PlayerHeight:array[Boolean] of Real=(0.3,1.6);
  189. RaumRange=8;
  190. Exploradius=4;
  191. Spawnradius=4;
  192. SpawnradiusNoSorte=7;
  193. SpawnradiusNoWalls=3;
  194. ViewFullscreen:Boolean=false;
  195. colortest=false;
  196. Debug=true;
  197. showMapCreateTime=false;
  198. Richtungen:array[TRichtung] of TRichtung=(px,nx,pz,nz);
  199. var
  200. StartSpeed:Real=15;
  201. start:Cardinal;
  202. GameEnded:Boolean=false;
  203. Camera:TGLCamera;
  204. PlayerGoalDistPanels:array of TGLHUDText;
  205. jumppressed:Boolean;
  206. log:TextFile;
  207. npl:TGLCylinder;
  208. Roomtypes:array of TRoomType;
  209. PanelConfigs:array of TPanelConfig;
  210. Players:array of TPlayer;
  211. MyID:Cardinal;
  212. MinGoalDist:Integer=22;
  213. MaxGoalDist:Integer=26;
  214. ShaderWidth:Integer=6;
  215. GoalProtectionRadius:Integer=2;
  216. inMenu:Boolean;
  217. Panel11Seconds,Panel13Seconds,RE1Seconds:Real;
  218. Form1: TForm1;
  219. Map:TMap;
  220. PosX,PosZ:Integer;
  221. playerarr:array of TGLCylinder;
  222. RoomInvisible,PlaneInvisible:array[-RaumRange..RaumRange,-RaumRange..RaumRange]
  223. of Boolean;
  224. Wallarr,DownWallArr,UpWallArr:
  225. array[0..1,-RaumRange..RaumRange+1,-RaumRange..RaumRange+1] of TGLCube;
  226. PlayerList:TList;
  227. MuhNPCArr:array[-RaumRange..RaumRange,-RaumRange..RaumRange] of
  228. TMuhNPC;
  229. PlaneArr:
  230. array of array[THeight,-RaumRange..RaumRange,-RaumRange..RaumRange] of
  231. TGLPlane;
  232. lasttime:Cardinal=0;
  233. PGoal:PRaum;
  234. GoalPos:TPoint;
  235. Lost,Won:Boolean;
  236. ThrustDrag:Boolean;
  237. SW:TMyStopWatch;
  238. implementation
  239. uses UNetwork, UMaterials, UCadencer, UMoveToRoom,UCreateRaum,UColorByID,
  240. UCheckmaze, UMessageThread, ShellAPI, UIni, IniFiles, UMainMenu, System.UITypes;
  241. {$R *.dfm}
  242. function GetRT(X,Z:Integer):PRoomtype;
  243. begin
  244. Result:=@Roomtypes[Map[X,Z].Inhalt.Sorte];
  245. end;
  246. function GetPC(X,Z:Integer):PPanelConfig;
  247. begin
  248. Result:=@PanelConfigs[Map[X,Z].Inhalt.Sorte];
  249. end;
  250. procedure TForm1.ChangeSpeedBy(DeltaSpeed:Real);
  251. begin
  252. Players[MyID].Speed:=Players[MyID].Speed+DeltaSpeed*ThrustBar.Position/1000;
  253. end;
  254. procedure TForm1.ChangeSpeedTo(NewSpeed:Real);
  255. begin
  256. Players[MyID].Speed:=NewSpeed*ThrustBar.Position/1000;
  257. end;
  258. procedure TForm1.MultiplySpeedBy(Factor:Real);
  259. begin
  260. Players[MyID].Speed:=Players[MyID].Speed*Factor;
  261. end;
  262. procedure TForm1.WinGame(ID: Cardinal);
  263. begin
  264. if Won then Exit;
  265. GameEnded:=true;
  266. if ID=MyID then begin
  267. Panel8.Font.Color:=RGB(25,150,25);
  268. Panel8.Color:=RGB(38,38,38);
  269. Panel8.Visible:=true;
  270. Panel8.Caption:='You win!';
  271. Panel9.Font.Color:=RGB(25,150,25);
  272. Panel9.Color:=RGB(38,38,38);
  273. Panel9.Visible:=true;
  274. Panel9.Caption:='Made by EBY aka Eror';
  275. ChangeSpeedBy(30);
  276. Won:=true;
  277. Beep;
  278. end else begin
  279. Panel8.Font.Color:=RGB(150,25,25);
  280. Panel8.Color:=RGB(38,38,38);
  281. Panel8.Visible:=true;
  282. Panel8.Caption:='Player '+IntToStr(ID)+' won the game!';
  283. LoseGame;
  284. end;
  285. end;
  286. procedure TForm1.LoseGame;
  287. begin
  288. Form3.SendPosition;
  289. if Lost then Exit;
  290. Players[MyID].Dead:=true;
  291. Form3.SendKill(MyID);
  292. Panel9.Font.Color:=RGB(150,25,25);
  293. Panel9.Color:=RGB(38,38,38);
  294. Panel9.Visible:=true;
  295. Panel9.Caption:='You Lose...';
  296. Lost:=true;
  297. Beep;
  298. end;
  299. procedure TForm1.RearrangePanels;
  300. var C2:Integer;
  301. begin
  302. MenuFont.Font.Size:=Round(OrigSizes[13]*self.Height);
  303. PlayerGoalDistFont.Font.Size:=Round(OrigSizes[14]*self.Height);
  304. for C2:=0 to High(PlayerGoalDistPanels) do
  305. PlayerGoalDistPanels[C2].Position.SetPoint
  306. (0.01*self.Width,Form1.PlayerGoalDistFont.Font.Size*(C2+0.5),0);
  307. Panel8.SetBounds(
  308. Round(self.Width*OrigSizes[5]),
  309. Round(self.Height*OrigSizes[7]),
  310. Round(self.Width*OrigSizes[6]),
  311. Round(self.Height*OrigSizes[8]));
  312. Panel9.SetBounds(
  313. Round(self.Width*OrigSizes[9]),
  314. Round(self.Height*OrigSizes[11]),
  315. Round(self.Width*OrigSizes[10]),
  316. Round(self.Height*OrigSizes[12]));
  317. MainMenu.Position.X:=self.Width*OrigSizes[15];
  318. MainMenu.Position.Y:=self.Height*OrigSizes[16];
  319. GLHUDText1.Position.X:=Round(self.Width*OrigSizes[21]);
  320. GLHUDText1.Position.Y:=Round(self.Height*OrigSizes[22]);
  321. GLHUDText2.Position.X:=Round(self.Width*OrigSizes[23]);
  322. GLHUDText2.Position.Y:=Round(self.Height*OrigSizes[24]);
  323. Panel13.SetBounds(
  324. Round(self.Width*OrigSizes[25]),
  325. Round(self.Height*OrigSizes[27]),
  326. Round(self.Width*OrigSizes[26]),
  327. Round(self.Height*OrigSizes[28]));
  328. Panel8.Font.Size:=Round(self.Width*OrigSizes[29]);
  329. Panel9.Font.Size:=Round(self.Width*OrigSizes[30]);
  330. Panel11.Font.Size:=Round(self.Width*OrigSizes[32]);
  331. MenuFont.Font.Size:=Round(self.Width*OrigSizes[33]);
  332. Panel13.Font.Size:=Round(self.Width*OrigSizes[34]);
  333. RichEdit1.SetBounds(
  334. Round(OrigSizes[35]*self.Width),
  335. Round(OrigSizes[37]*self.Height),
  336. Round(OrigSizes[36]*self.Width),
  337. Round(OrigSizes[38]*self.Height));
  338. RichEdit1.Font.SIZE:=Round(OrigSizes[39]*self.Height);
  339. SettingsMenu.Position.X:=self.Width*OrigSizes[40];
  340. SettingsMenu.Position.Y:=self.Height*OrigSizes[41];
  341. VideoMenu.Position.X:=self.Width*OrigSizes[42];
  342. VideoMenu.Position.Y:=self.Height*OrigSizes[43];
  343. MPMenu.Position.X:=self.Width*OrigSizes[46];
  344. MPMenu.Position.Y:=self.Height*OrigSizes[47];
  345. MPHostMenu.Position.X:=self.Width*OrigSizes[48];
  346. MPHostMenu.Position.Y:=self.Height*OrigSizes[49];
  347. MPJoinMenu.Position.X:=self.Width*OrigSizes[50];
  348. MPJoinMenu.Position.Y:=self.Height*OrigSizes[51];
  349. ThrustBar.Top:=Round(self.Height*OrigSizes[52]);
  350. ThrustBar.Left:=Round(self.Width*OrigSizes[53]);
  351. ThrustBar.Height:=Round(self.Height*OrigSizes[54]);
  352. ThrustBar.Width:=Round(self.Width*OrigSizes[55]);
  353. end;
  354. procedure TForm1.ReloadRoom(X,Z:Integer);
  355. var C1,C2:Integer;
  356. begin
  357. if (X<PosX-RaumRange)
  358. or (X>PosX+RaumRange)
  359. or (Z<PosZ-RaumRange)
  360. or (Z>PosZ+RaumRange) then
  361. Exit;
  362. if not Map[X,Z].created then CreateRaum(X,Z);
  363. if RoomInvisible[X-PosX,Z-PosZ] then begin
  364. Wallarr[0,X-posX,Z-PosZ].Visible:=false;
  365. Wallarr[1,X-posX,Z-PosZ].Visible:=false;
  366. UpWallarr[0,X-posX,Z-PosZ].Visible:=false;
  367. UpWallarr[1,X-posX,Z-PosZ].Visible:=false;
  368. DownWallarr[0,X-posX,Z-PosZ].Visible:=false;
  369. DownWallarr[1,X-posX,Z-PosZ].Visible:=false;
  370. for C1:=0 to High(Roomtypes) do begin
  371. PlaneArr[C1,Down,X-posX,Z-PosZ].Visible:=false;
  372. PlaneArr[C1,Up,X-posX,Z-PosZ].Visible:=false;
  373. end;
  374. MuhNPCArr[X-posX,Z-posZ].Body.Visible:=false;
  375. Exit;
  376. end;
  377. if Map[X-1,Z].Inhalt.Sorte<>Integer(Green) then begin
  378. activateWall(0,X-posX,Z-posZ,nx in Map[X,Z].Walls);
  379. activateUpWall(0,X-posX,Z-posZ,nx in Map[X,Z].UpWalls);
  380. activateDownWall(0,X-posX,Z-posZ,nx in Map[X,Z].DownWalls);
  381. end;
  382. if Map[X+1,Z].Inhalt.Sorte<>Integer(Green) then begin
  383. activateWall(0,X+1-posX,Z-posZ,px in Map[X,Z].Walls);
  384. activateUpWall(0,X+1-posX,Z-posZ,px in Map[X,Z].UpWalls);
  385. activateDownWall(0,X+1-posX,Z-posZ,px in Map[X,Z].DownWalls);
  386. end;
  387. if Map[X,Z-1].Inhalt.Sorte<>Integer(Green) then begin
  388. activateWall(1,X-posX,Z-posZ,nz in Map[X,Z].Walls);
  389. activateUpWall(1,X-posX,Z-posZ,nz in Map[X,Z].UpWalls);
  390. activateDownWall(1,X-posX,Z-posZ,nz in Map[X,Z].DownWalls);
  391. end;
  392. if Map[X,Z+1].Inhalt.Sorte<>Integer(Green) then begin
  393. activateWall(1,X-posX,Z-posZ+1,pz in Map[X,Z].Walls);
  394. activateUpWall(1,X-posX,Z-posZ+1,pz in Map[X,Z].UpWalls);
  395. activateDownWall(1,X-posX,Z-posZ+1,pz in Map[X,Z].DownWalls);
  396. end;
  397. activateGreen(X-PosX,Z-posZ,Map[X,Z].Inhalt.Sorte=Integer(Green));
  398. if PlaneInvisible[X-PosX,Z-PosZ] then begin
  399. for C1:=0 to High(Roomtypes) do begin
  400. PlaneArr[C1,Down,X-posX,Z-PosZ].Visible:=false;
  401. PlaneArr[C1,Up,X-posX,Z-PosZ].Visible:=false;
  402. end;
  403. MuhNPCArr[X-posX,Z-posZ].Body.Visible:=false;
  404. Exit;
  405. end;
  406. for C1:=0 to High(Roomtypes) do begin
  407. PlaneArr[C1,Down,X-PosX,Z-PosZ].Visible:=Map[X,Z].Inhalt.Sorte=C1;
  408. if Map[X,Z].Inhalt.Sorte=C1 then begin
  409. for C2:=C1+1 to High(Roomtypes) do
  410. if PlaneArr[C1,Down,X-PosX,Z-PosZ]<>PlaneArr[C2,Down,X-PosX,Z-PosZ]
  411. then PlaneArr[C2,Down,X-PosX,Z-PosZ].Visible:=false;
  412. Break;
  413. end;
  414. end;
  415. for C1:=0 to High(Roomtypes) do begin
  416. PlaneArr[C1,Up,X-PosX,Z-PosZ].Visible:=Map[X,Z].Inhalt.Sorte=C1;
  417. if Map[X,Z].Inhalt.Sorte=C1 then begin
  418. for C2:=C1+1 to High(Roomtypes) do
  419. if PlaneArr[C1,Up,X-PosX,Z-PosZ]<>PlaneArr[C2,Up,X-PosX,Z-PosZ]
  420. then PlaneArr[C2,Up,X-PosX,Z-PosZ].Visible:=false;
  421. Break;
  422. end;
  423. end;
  424. if (GetRT(X,Z).SPInvisible)
  425. and not Form3.ClientSocket.Active
  426. and not Form3.ServerSocket.Active then begin
  427. for C1:=1 to High(Roomtypes) do begin
  428. PlaneArr[C1,Down,X-PosX,Z-PosZ].Visible:=false;
  429. PlaneArr[C1,Up,X-PosX,Z-PosZ].Visible:=false;
  430. end;
  431. MuhNPCArr[X-posX,Z-posZ].Body.Visible:=false;
  432. PlaneArr[0,Down,X-PosX,Z-PosZ].Visible:=true;
  433. PlaneArr[0,Up,X-PosX,Z-PosZ].Visible:=true;
  434. Exit;
  435. end;
  436. if GetRT(X,Z).TurnRandom[Up] then
  437. if Assigned(Map[X,Z].Inhalt.Daten) then
  438. case TRichtung(Map[X,Z].Inhalt.Daten^) of
  439. pz:Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=0;
  440. nx:Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=90;
  441. nz:Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=180;
  442. px:Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=270;
  443. end;
  444. if GetRT(X,Z).TurnRandom[Down] then
  445. if Assigned(Map[X,Z].Inhalt.Daten) then
  446. case TRichtung(Map[X,Z].Inhalt.Daten^) of
  447. pz:Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=180;
  448. nx:Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=90;
  449. nz:Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=0;
  450. px:Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=270;
  451. end;
  452. if GetRT(X,Z).TurnToGoal[Up] then
  453. if Abs(GoalPos.X-X)>Abs(GoalPos.Y-Z) then begin
  454. if GoalPos.X-X>0 then
  455. Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=-90//px
  456. else
  457. Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=90//nx
  458. end else begin
  459. if GoalPos.Y-Z>0 then
  460. Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=0//pz
  461. else
  462. Planearr[Map[X,Z].Inhalt.Sorte,Up,x-PosX,z-posZ].RollAngle:=180//nz
  463. end;
  464. if GetRT(X,Z).TurnToGoal[Down] then
  465. if Abs(GoalPos.X-X)>Abs(GoalPos.Y-Z) then begin
  466. if GoalPos.X-X>0 then
  467. Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=-90//px
  468. else
  469. Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=90//nx
  470. end else begin
  471. if GoalPos.Y-Z>0 then
  472. Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=180//pz
  473. else
  474. Planearr[Map[X,Z].Inhalt.Sorte,Down,x-PosX,z-posZ].RollAngle:=0//nu
  475. end;
  476. MuhNPCArr[X-posX,Z-posZ].Body.Visible:=GetRT(X,Z).OPTanzGegner;
  477. end;
  478. procedure TForm1.Reload;
  479. var C1,C3,C2:Integer;
  480. begin
  481. CameraDirection:=Ceil(Camera.Direction.X)+2*Ceil(Camera.Direction.Z);
  482. for C1:=-RaumRange to RaumRange do
  483. for C2:=-RaumRange to RaumRange do begin
  484. RoomInvisible[C1,C2]:=false;
  485. PlaneInvisible[C1,C2]:=false;
  486. end;
  487. if GetRT(PosX,PosZ).GreenWallsAround then
  488. for C1:=-RaumRange to RaumRange do
  489. for C2:=-RaumRange to RaumRange do begin
  490. RoomInvisible[C1,C2]:=true;
  491. PlaneInvisible[C1,C2]:=true;
  492. end;
  493. if not Players[MyID].OutOfMaze then begin
  494. for C2:=1 to RaumRange do
  495. if (nx in Map[C2+PosX,PosZ].Walls)
  496. or (GetRT(C2+PosX,PosZ).GreenWallsAround) then begin
  497. PlaneInvisible[C2,0]:=true;
  498. for C1:=C2+1 to RaumRange do
  499. RoomInvisible[C1,0]:=true;
  500. Break;
  501. end;
  502. for C2:=1 to RaumRange do
  503. if (nz in Map[PosX,C2+PosZ].Walls)
  504. or (GetRT(PosX,C2+PosZ).GreenWallsAround) then begin
  505. PlaneInvisible[0,C2]:=true;
  506. for C1:=C2+1 to RaumRange do
  507. RoomInvisible[0,C1]:=true;
  508. Break;
  509. end;
  510. for C2:=-1 downto -RaumRange do
  511. if (pz in Map[PosX,C2+PosZ].Walls)
  512. or (GetRT(PosX,C2+PosZ).GreenWallsAround) then begin
  513. PlaneInvisible[0,C2]:=true;
  514. for C1:=C2-1 downto -RaumRange do
  515. RoomInvisible[0,C1]:=true;
  516. Break;
  517. end;
  518. for C2:=-1 downto -RaumRange do
  519. if (px in Map[C2+PosX,PosZ].Walls)
  520. or (GetRT(C2+PosX,PosZ).GreenWallsAround) then begin
  521. PlaneInvisible[C2,0]:=true;
  522. for C1:=C2-1 downto -RaumRange do
  523. RoomInvisible[C1,0]:=true;
  524. Break;
  525. end;
  526. if (((px in Map[PosX,PosZ].Walls)
  527. or (GetRT(PosX+1,PosZ).GreenWallsAround))
  528. and ((pz in Map[PosX,PosZ].Walls)
  529. or (GetRT(PosX,PosZ+1).GreenWallsAround)))
  530. or (CameraDirection=0) then
  531. for C1:=1 to RaumRange do
  532. for C2:=1 to RaumRange do begin
  533. RoomInvisible[C1,C2]:=true;
  534. end;
  535. if (((px in Map[PosX,PosZ].Walls)
  536. or (GetRT(PosX+1,PosZ).GreenWallsAround))
  537. and ((nz in Map[PosX,PosZ].Walls)
  538. or (GetRT(PosX,PosZ-1).GreenWallsAround)))
  539. or (CameraDirection=2) then
  540. for C1:=1 to RaumRange do
  541. for C2:=-1 downto -RaumRange do begin
  542. RoomInvisible[C1,C2]:=true;
  543. end;
  544. if (((nx in Map[PosX,PosZ].Walls)
  545. or (GetRT(PosX-1,PosZ).GreenWallsAround))
  546. and ((nz in Map[PosX,PosZ].Walls)
  547. or (GetRT(PosX,PosZ-1).GreenWallsAround)))
  548. or (CameraDirection=3) then
  549. for C1:=-1 downto -RaumRange do
  550. for C2:=-1 downto -RaumRange do begin
  551. RoomInvisible[C1,C2]:=true;
  552. end;
  553. if (((nx in Map[PosX,PosZ].Walls)
  554. or (GetRT(PosX-1,PosZ).GreenWallsAround))
  555. and ((pz in Map[PosX,PosZ].Walls)
  556. or (GetRT(PosX,PosZ+1).GreenWallsAround)))
  557. or (CameraDirection=1) then
  558. for C1:=-1 downto -RaumRange do
  559. for C2:=1 to RaumRange do begin
  560. RoomInvisible[C1,C2]:=true;
  561. end;
  562. for C1:=-1 to 1 do begin
  563. RoomInvisible[C1,0]:=false;
  564. RoomInvisible[0,C1]:=false;
  565. end;
  566. PlaneInvisible[0,0]:=false;
  567. end;
  568. for C1:=PosX-RaumRange to PosX+RaumRange do
  569. for C3:=PosZ-RaumRange to PosZ+RaumRange do
  570. ReloadRoom(C1,C3);
  571. ReloadWallShaders;
  572. ReloadTexQual;
  573. end;
  574. procedure TForm1.ReloadWallShaders;
  575. var C1,C3:Integer;
  576. begin
  577. for C1:=-RaumRange to RaumRange+1 do
  578. for C3:=-RaumRange to RaumRange+1 do
  579. if (C1<-ShaderWidth+1)
  580. or (C3<-ShaderWidth+1)
  581. or (C1>ShaderWidth)
  582. or (C3>ShaderWidth) then begin
  583. if Wallarr[0,C1,C3].Material.LibMaterialName='Wall'
  584. then Wallarr[0,C1,C3].Material.LibMaterialName:='WallFar';
  585. if Wallarr[1,C1,C3].Material.LibMaterialName='Wall'
  586. then Wallarr[1,C1,C3].Material.LibMaterialName:='WallFar';
  587. if UpWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  588. then UpWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallFar';
  589. if UpWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  590. then UpWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallFar';
  591. if DownWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  592. then DownWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallFar';
  593. if DownWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  594. then DownWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallFar';
  595. end;
  596. end;
  597. procedure TForm1.ReloadTexQual;
  598. var C1,C3:Integer;
  599. const HiResRad=3; LowResRad=6;
  600. begin
  601. for C1:=-RaumRange to RaumRange+1 do
  602. for C3:=-RaumRange to RaumRange+1 do
  603. if sqrt(sqr(C1)+sqr(C3))>LowResRad then begin
  604. if Wallarr[0,C1,C3].Material.LibMaterialName='Wall'
  605. then Wallarr[0,C1,C3].Material.LibMaterialName:='WallVeryLowRes';
  606. if Wallarr[1,C1,C3].Material.LibMaterialName='Wall'
  607. then Wallarr[1,C1,C3].Material.LibMaterialName:='WallVeryLowRes';
  608. if UpWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  609. then UpWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallVeryLowRes';
  610. if UpWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  611. then UpWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallVeryLowRes';
  612. if DownWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  613. then DownWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallVeryLowRes';
  614. if DownWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  615. then DownWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallVeryLowRes';
  616. end else
  617. if sqrt(sqr(C1)+sqr(C3))>HiResRad then begin
  618. if Wallarr[0,C1,C3].Material.LibMaterialName='Wall'
  619. then Wallarr[0,C1,C3].Material.LibMaterialName:='WallLowRes';
  620. if Wallarr[1,C1,C3].Material.LibMaterialName='Wall'
  621. then Wallarr[1,C1,C3].Material.LibMaterialName:='WallLowRes';
  622. if UpWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  623. then UpWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallLowRes';
  624. if UpWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  625. then UpWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallLowRes';
  626. if DownWallarr[0,C1,C3].Material.LibMaterialName='HalfWall'
  627. then DownWallarr[0,C1,C3].Material.LibMaterialName:='HalfWallLowRes';
  628. if DownWallarr[1,C1,C3].Material.LibMaterialName='HalfWall'
  629. then DownWallarr[1,C1,C3].Material.LibMaterialName:='HalfWallLowRes';
  630. end;
  631. end;
  632. procedure TForm1.Timer1Timer(Sender: TObject);
  633. begin
  634. GLHUDText2.Visible:=inMenu;
  635. if VideoMenu.Visible then begin
  636. VideoMenu.Items[2]:='Shading Distance: '+IntToStr(ShaderWidth);
  637. end;
  638. if MPHostMenu.Visible then begin
  639. MPHostMenu.Items[0]:='Port: '+IntToStr(MPPort);
  640. end;
  641. if MPJoinMenu.Visible then begin
  642. MPJoinMenu.Items[0]:='Server-IP: '+MPServerAddress;
  643. MPJoinMenu.Items[1]:='Port: '+IntToStr(MPPort);
  644. end;
  645. GLSceneViewer1MouseMove(
  646. Sender,[],Form1.ScreenToClient(Mouse.CursorPos).X,
  647. Form1.ScreenToClient(Mouse.CursorPos).Y);
  648. CalcFPS(TTimer(Sender).Interval/1000);
  649. if Panel1.Visible then
  650. Panel1.Caption:=floatToStr(Round(100*FPS)/100);
  651. Self.Caption:='Randomaze FPS: '+floatToStr(Round(100*FPS)/100);
  652. if Panel11.Visible then begin
  653. Panel11Seconds:=Panel11Seconds-TTimer(Sender).Interval/1000;
  654. if Panel11Seconds<0.01 then begin //Float Comparison
  655. Panel11Seconds:=0;
  656. Panel11.Visible:=false;
  657. end;
  658. end;
  659. //todo 1:panel11 position in panelconfig, RichEdit1 in origsizes
  660. if RichEdit1.Visible then begin
  661. RE1Seconds:=RE1Seconds-TTimer(Sender).Interval/1000;
  662. if RE1Seconds<0.01 then begin //Float Comparison
  663. RE1Seconds:=0;
  664. RichEdit1.Visible:=false;
  665. end;
  666. end;
  667. if Panel13.Visible then begin
  668. Panel13Seconds:=Panel13Seconds-TTimer(Sender).Interval/1000;
  669. if Panel13Seconds<0.01 then begin //Float Comparison
  670. Panel13Seconds:=0;
  671. Panel13.Visible:=false;
  672. end;
  673. end;
  674. if Panel2.Visible then
  675. Panel2.Caption:=
  676. FloatToStr(Round(100*GLCamera1.Position.X)/100)+','
  677. +FloatToStr(Round(100*GLCamera1.Position.Y)/100)+','
  678. +FloatToStr(Round(100*GLCamera1.Position.Z)/100);
  679. if Panel3.Visible then
  680. Panel3.Caption:=BoolToStr(players[MyId].CeilWalk,true);
  681. if Panel4.Visible then
  682. Panel4.Caption:=BoolToStr(won,true)+','+BoolToStr(lost,true);
  683. if Panel6.Visible then
  684. Panel6.Caption:=IntToStr(PosX)+','+IntToStr(PosZ);
  685. if Players[MyID].Speed<=0.01 then
  686. if IDRecieved then begin
  687. Panel8.Font.Color:=RGB(150,25,25);
  688. Panel8.Color:=RGB(38,38,38);
  689. Panel8.Visible:=true;
  690. Panel8.Caption:='Anticamper:';
  691. LoseGame;
  692. end;
  693. end;
  694. function TForm1.NewWall(x,z:Integer; width,depth:Real):TGLCube;
  695. begin
  696. Result:=TGLCube(Walls.AddNewChild(TGLCube));
  697. Result.Position.X:=x;
  698. Result.Position.Y:=1;
  699. Result.Position.Z:=z;
  700. Result.CubeWidth:=width;
  701. Result.CubeHeight:=6;
  702. Result.CubeDepth:=depth;
  703. Result.Material.MaterialLibrary:=Form2.GLMaterialLibrary1;
  704. Result.Material.LibMaterialName:='Wall';
  705. end;
  706. function TForm1.NewMuhNPCBody(X,Z:Integer):TGLCube;
  707. begin
  708. Result:=TGLCube(MuhNPCs.AddNewChild(TGLCube));
  709. Result.Position.X:=20*X;
  710. Result.Position.Y:=0;
  711. Result.Position.Z:=20*Z;
  712. Result.CubeWidth:=2;
  713. Result.CubeHeight:=2;
  714. Result.CubeDepth:=2;
  715. Result.Material.MaterialLibrary:=Form2.GLMaterialLibrary1;
  716. Result.Material.LibMaterialName:='Muh';
  717. end;
  718. function TForm1.NewUpWall(x,z:Integer; width,depth:Real):TGLCube;
  719. begin
  720. Result:=TGLCube(Walls.AddNewChild(TGLCube));
  721. Result.Position.X:=x;
  722. Result.Position.Y:=2.5;
  723. Result.Position.Z:=z;
  724. Result.CubeWidth:=width;
  725. Result.CubeHeight:=3;
  726. Result.CubeDepth:=depth;
  727. Result.Material.MaterialLibrary:=Form2.GLMaterialLibrary1;
  728. Result.Material.LibMaterialName:='HalfWall';
  729. end;
  730. function TForm1.NewDownWall(x,z:Integer; width,depth:Real):TGLCube;
  731. begin
  732. Result:=TGLCube(Walls.AddNewChild(TGLCube));
  733. Result.Position.X:=x;
  734. Result.Position.Y:=-0.5;
  735. Result.Position.Z:=z;
  736. Result.CubeWidth:=width;
  737. Result.CubeHeight:=3;
  738. Result.CubeDepth:=depth;
  739. Result.Material.MaterialLibrary:=Form2.GLMaterialLibrary1;
  740. Result.Material.LibMaterialName:='HalfWall';
  741. end;
  742. procedure TForm1.SpreadContamination(X,Z:Integer);
  743. var C1,C2:Integer; R1:Real; Pos:TPoint;
  744. begin
  745. for C1:=X-1 to X+1 do
  746. for C2:=Z-1 to Z+1 do begin
  747. R1:=Random;
  748. if R1<0.3 then begin
  749. Map[C1,C2].Inhalt.Sorte:=Map[X,Z].Inhalt.Sorte;
  750. if GetRT(C1,C2).TurnRandom[Down]
  751. or GetRT(C1,C2).TurnRandom[Up]
  752. then Map[C1,C2].Inhalt.Daten:=@Richtungen[
  753. TRichtung(Random(Integer(High(TRichtung))+1))]
  754. end else if R1<0.5 then
  755. Map[C1,C2].Inhalt.Sorte:=0;
  756. if R1<0.5 then
  757. if Form3.ServerSocket.Active then begin
  758. Pos.X:=C1;
  759. Pos.Y:=C2;
  760. Form3.SendRaum(Pos);
  761. end;
  762. end;
  763. end;
  764. procedure TForm1.ShowPanel(ID:Cardinal);
  765. begin
  766. Panel11.Top:=Round(PanelConfigs[ID].TopDivH*Self.Height);
  767. Panel11.Left:=Round(PanelConfigs[ID].LeftDivW*Self.Width);
  768. Panel11.Width:=Round(PanelConfigs[ID].WidthDivW*Self.Width);
  769. Panel11.Height:=Round(PanelConfigs[ID].HeightDivH*Self.Height);
  770. Panel11.Caption:=PanelConfigs[ID].Text;
  771. if PanelConfigs[ID].SpeedAtEnd then
  772. Panel11.Caption:=Panel11.Caption+' '+
  773. Floattostr(Round(100*Players[MyID].Speed)/100);
  774. Panel11.Font.Color:=PanelConfigs[ID].FontColor;
  775. Panel11.Color:=PanelConfigs[ID].BackGroundColor;
  776. Panel11.Font.SIZE:=Round(PanelConfigs[ID].FontSizeDivH*Self.Height);
  777. Panel11Seconds:=PanelConfigs[ID].Seconds;
  778. Panel11.Visible:=true;
  779. end;
  780. procedure TForm1.Explode(X,Z:Integer);
  781. var C1,C2:Integer;
  782. begin
  783. if (X=PosX) and (Z=PosZ) then
  784. Form1.ShowPanel(14);//todo 1:testen
  785. if GetRT(X,Z).Explode[Up]
  786. or GetRT(X,Z).Explode[Down] then
  787. Map[X,Z].Inhalt.Sorte:=0;
  788. for C1:=X-Exploradius to X+Exploradius do
  789. for C2:=Z-Exploradius to Z+Exploradius do
  790. if (C1<MapSize)
  791. and (C1>-MapSize)
  792. and (C2<MapSize)
  793. and (C2>-MapSize) then begin
  794. if not Map[C1,C2].created then CreateRaum(C1,C2);
  795. if sqrt(sqr(X-C1)+sqr(Z-C2))<Exploradius then begin
  796. Map[C1,C2].Walls:=[];
  797. Map[C1+1,C2].Walls:=Map[C1+1,C2].Walls-[nx];
  798. Map[C1,C2+1].Walls:=Map[C1,C2+1].Walls-[nz];
  799. Map[C1,C2-1].Walls:=Map[C1,C2-1].Walls-[pz];
  800. Map[C1-1,C2].Walls:=Map[C1-1,C2].Walls-[px];
  801. Map[C1,C2].UpWalls:=[];
  802. Map[C1+1,C2].UpWalls:=Map[C1+1,C2].UpWalls-[nx];
  803. Map[C1,C2+1].UpWalls:=Map[C1,C2+1].UpWalls-[nz];
  804. Map[C1,C2-1].UpWalls:=Map[C1,C2-1].UpWalls-[pz];
  805. Map[C1-1,C2].UpWalls:=Map[C1-1,C2].UpWalls-[px];
  806. Map[C1,C2].DownWalls:=[];
  807. Map[C1+1,C2].DownWalls:=Map[C1+1,C2].DownWalls-[nx];
  808. Map[C1,C2+1].DownWalls:=Map[C1,C2+1].DownWalls-[nz];
  809. Map[C1,C2-1].DownWalls:=Map[C1,C2-1].DownWalls-[pz];
  810. Map[C1-1,C2].DownWalls:=Map[C1-1,C2].DownWalls-[px];
  811. if not Won then begin
  812. if (Map[C1,C2].Inhalt.Sorte=Integer(GreenTrap))
  813. then begin
  814. Map[C1,C2].Inhalt.Sorte:=Integer(Green);
  815. end;
  816. if (Map[C1+1,C2].Inhalt.Sorte=Integer(GreenTrap))
  817. then begin
  818. Map[C1+1,C2].Inhalt.Sorte:=Integer(Green);
  819. end;
  820. if (Map[C1,C2+1].Inhalt.Sorte=Integer(GreenTrap))
  821. then begin
  822. Map[C1,C2+1].Inhalt.Sorte:=Integer(Green);
  823. end;
  824. if (Map[C1-1,C2].Inhalt.Sorte=Integer(GreenTrap))
  825. then begin
  826. Map[C1-1,C2].Inhalt.Sorte:=Integer(Green);
  827. end;
  828. if (Map[C1,C2-1].Inhalt.Sorte=Integer(GreenTrap))
  829. then begin
  830. Map[C1,C2-1].Inhalt.Sorte:=Integer(Green);
  831. Form3.SendRaumSorte(C1,C2-1);
  832. end;
  833. end;
  834. if (Map[C1,C2].Inhalt.Sorte=Integer(Explosion))
  835. then Explode(C1,C2);
  836. if (Map[C1+1,C2].Inhalt.Sorte=Integer(Explosion))
  837. then Explode(C1+1,C2);
  838. if (Map[C1,C2+1].Inhalt.Sorte=Integer(Explosion))
  839. then Explode(C1,C2);
  840. if (Map[C1-1,C2].Inhalt.Sorte=Integer(Explosion))
  841. then Explode(C1-1,C2);
  842. if (Map[C1,C2-1].Inhalt.Sorte=Integer(Explosion))
  843. then Explode(C1,C2-1);
  844. end;
  845. end;
  846. end;
  847. function TForm1.NewPlayer(ID:Integer):TGLCylinder;
  848. var R,G,B:Real;
  849. begin
  850. Result:=TGLCylinder(OtherPlayers.AddNewChild(TGLCylinder));
  851. Result.Slices:=50;
  852. Result.Height:=PlayerDepth[false]+PlayerHeight[false];
  853. Result.Position.Y:=-2+(PlayerDepth[false]+PlayerHeight[false])/2;
  854. Result.TopRadius:=1;
  855. Result.BottomRadius:=1;
  856. Result.Up.SetVector(0,1,0);
  857. RedbyID(ID,R);
  858. GreenbyID(ID,G);
  859. BluebyID(ID,B);
  860. Result.Material.FrontProperties.Ambient.SetColor(R,G,B);
  861. Result.Material.FrontProperties.Diffuse.SetColor(R,G,B);
  862. Result.Material.FrontProperties.Emission.SetColor(R,G,B);
  863. Result.Material.BackProperties.Ambient.SetColor(R,G,B);
  864. Result.Material.BackProperties.Diffuse.SetColor(R,G,B);
  865. Result.Material.BackProperties.Emission.SetColor(R,G,B);
  866. end;
  867. function TForm1.NewPlane(x,z:Integer; Height:THeight;
  868. Sorte:Integer):TGLPlane;
  869. const HiResRad=1.5; LowResRad=3;
  870. begin
  871. Result:=TGLPlane(Planes.AddNewChild(TGLPlane));
  872. Result.Position.X:=x*20;
  873. if Height=Down then
  874. Result.Position.Y:=-2
  875. else Result.Position.Y:=4;
  876. Result.Position.Z:=z*20;
  877. Result.Width:=20;
  878. Result.Height:=20;
  879. if Height=Down then
  880. Result.PitchAngle:=90
  881. else
  882. Result.PitchAngle:=-90;
  883. Result.Material.MaterialLibrary:=Form2.GLMaterialLibrary1;
  884. Result.Material.LibMaterialName:=Roomtypes[Sorte].MaterialName[Height];
  885. if sqrt(sqr(x)+sqr(z))>LowResRad then begin
  886. if (Roomtypes[Sorte].MaterialName[Height]='Grass') then
  887. Result.Material.LibMaterialName:='GrassVeryLowRes';
  888. if (Roomtypes[Sorte].MaterialName[Height]='Ceiling') then
  889. Result.Material.LibMaterialName:='CeilingVeryLowRes';
  890. end else if sqrt(sqr(x)+sqr(z))>HiResRad then begin
  891. if (Roomtypes[Sorte].MaterialName[Height]='Grass') then
  892. Result.Material.LibMaterialName:='GrassLowRes';
  893. if (Roomtypes[Sorte].MaterialName[Height]='Ceiling') then
  894. Result.Material.LibMaterialName:='CeilingLowRes';
  895. end;
  896. end;
  897. procedure TForm1.activateWall(dir,x,z:Integer; activate:Boolean);
  898. begin
  899. Wallarr[dir,x,z].Visible:=activate;
  900. end;
  901. procedure TForm1.activateUpWall(dir,x,z:Integer; activate:Boolean);
  902. begin
  903. UpWallarr[dir,x,z].Visible:=activate;
  904. end;
  905. procedure TForm1.activateDownWall(dir,x,z:Integer; activate:Boolean);
  906. begin
  907. DownWallarr[dir,x,z].Visible:=activate;
  908. end;
  909. procedure TForm1.activateGreen(X,Z:Integer; activate:Boolean);
  910. begin
  911. if activate then begin
  912. if nx in Map[x+PosX,z+PosZ].UpWalls then begin
  913. DownWallarr[0,X,Z].Material.LibMaterialName:='HalfGreenWall';
  914. UpWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  915. Wallarr[0,X,Z].Material.LibMaterialName:='Wall';
  916. DownWallarr[0,X,Z].Visible:=true;
  917. UpWallarr[0,X,Z].Visible:=true;
  918. Wallarr[0,X,Z].Visible:=false;
  919. end else if nx in Map[x+PosX,z+PosZ].DownWalls then begin
  920. DownWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  921. UpWallarr[0,X,Z].Material.LibMaterialName:='HalfGreenWall';
  922. Wallarr[0,X,Z].Material.LibMaterialName:='Wall';
  923. DownWallarr[0,X,Z].Visible:=true;
  924. UpWallarr[0,X,Z].Visible:=true;
  925. Wallarr[0,X,Z].Visible:=false;
  926. end else if not (nx in Map[x+PosX,z+PosZ].Walls) then begin
  927. DownWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  928. UpWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  929. Wallarr[0,X,Z].Material.LibMaterialName:='GreenWall';
  930. DownWallarr[0,X,Z].Visible:=false;
  931. UpWallarr[0,X,Z].Visible:=false;
  932. Wallarr[0,X,Z].Visible:=true;
  933. end else begin
  934. DownWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  935. UpWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  936. Wallarr[0,X,Z].Material.LibMaterialName:='Wall';
  937. DownWallarr[0,X,Z].Visible:=false;
  938. UpWallarr[0,X,Z].Visible:=false;
  939. Wallarr[0,X,Z].Visible:=true;
  940. end;
  941. if px in Map[x+PosX,z+PosZ].UpWalls then begin
  942. DownWallarr[0,X+1,Z].Material.LibMaterialName:='HalfGreenWall';
  943. UpWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  944. Wallarr[0,X+1,Z].Material.LibMaterialName:='Wall';
  945. DownWallarr[0,X+1,Z].Visible:=true;
  946. UpWallarr[0,X+1,Z].Visible:=true;
  947. Wallarr[0,X+1,Z].Visible:=false;
  948. end else if px in Map[x+PosX,z+PosZ].DownWalls then begin
  949. DownWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  950. UpWallarr[0,X+1,Z].Material.LibMaterialName:='HalfGreenWall';
  951. Wallarr[0,X+1,Z].Material.LibMaterialName:='Wall';
  952. DownWallarr[0,X+1,Z].Visible:=true;
  953. UpWallarr[0,X+1,Z].Visible:=true;
  954. Wallarr[0,X+1,Z].Visible:=false;
  955. end else if not (px in Map[x+PosX,z+PosZ].Walls) then begin
  956. DownWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  957. UpWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  958. Wallarr[0,X+1,Z].Material.LibMaterialName:='GreenWall';
  959. DownWallarr[0,X+1,Z].Visible:=false;
  960. UpWallarr[0,X+1,Z].Visible:=false;
  961. Wallarr[0,X+1,Z].Visible:=true;
  962. end else begin
  963. DownWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  964. UpWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  965. Wallarr[0,X+1,Z].Material.LibMaterialName:='Wall';
  966. DownWallarr[0,X+1,Z].Visible:=false;
  967. UpWallarr[0,X+1,Z].Visible:=false;
  968. Wallarr[0,X+1,Z].Visible:=true;
  969. end;
  970. if nz in Map[x+PosX,z+PosZ].UpWalls then begin
  971. DownWallarr[1,X,Z].Material.LibMaterialName:='HalfGreenWall';
  972. UpWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  973. Wallarr[1,X,Z].Material.LibMaterialName:='Wall';
  974. DownWallarr[1,X,Z].Visible:=true;
  975. UpWallarr[1,X,Z].Visible:=true;
  976. Wallarr[1,X,Z].Visible:=false;
  977. end else if nz in Map[x+PosX,z+PosZ].DownWalls then begin
  978. DownWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  979. UpWallarr[1,X,Z].Material.LibMaterialName:='HalfGreenWall';
  980. Wallarr[1,X,Z].Material.LibMaterialName:='Wall';
  981. DownWallarr[1,X,Z].Visible:=true;
  982. UpWallarr[1,X,Z].Visible:=true;
  983. Wallarr[1,X,Z].Visible:=false;
  984. end else if not (nz in Map[x+PosX,z+PosZ].Walls) then begin
  985. DownWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  986. UpWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  987. Wallarr[1,X,Z].Material.LibMaterialName:='GreenWall';
  988. DownWallarr[1,X,Z].Visible:=false;
  989. UpWallarr[1,X,Z].Visible:=false;
  990. Wallarr[1,X,Z].Visible:=true;
  991. end else begin
  992. DownWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  993. UpWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  994. Wallarr[1,X,Z].Material.LibMaterialName:='Wall';
  995. DownWallarr[1,X,Z].Visible:=false;
  996. UpWallarr[1,X,Z].Visible:=false;
  997. Wallarr[1,X,Z].Visible:=true;
  998. end;
  999. if pz in Map[X+PosX,Z+PosZ].UpWalls then begin
  1000. DownWallarr[1,X,Z+1].Material.LibMaterialName:='HalfGreenWall';
  1001. UpWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1002. Wallarr[1,X,Z+1].Material.LibMaterialName:='Wall';
  1003. DownWallarr[1,X,Z+1].Visible:=true;
  1004. UpWallarr[1,X,Z+1].Visible:=true;
  1005. Wallarr[1,X,Z+1].Visible:=false;
  1006. end else if pz in Map[x+PosX,z+PosZ].DownWalls then begin
  1007. DownWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1008. UpWallarr[1,X,Z+1].Material.LibMaterialName:='HalfGreenWall';
  1009. Wallarr[1,X,Z+1].Material.LibMaterialName:='Wall';
  1010. DownWallarr[1,X,Z+1].Visible:=true;
  1011. UpWallarr[1,X,Z+1].Visible:=true;
  1012. Wallarr[1,X,Z+1].Visible:=false;
  1013. end else if not (pz in Map[x+PosX,z+PosZ].Walls) then begin
  1014. DownWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1015. UpWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1016. Wallarr[1,X,Z+1].Material.LibMaterialName:='GreenWall';
  1017. DownWallarr[1,X,Z+1].Visible:=false;
  1018. UpWallarr[1,X,Z+1].Visible:=false;
  1019. Wallarr[1,X,Z+1].Visible:=true;
  1020. end else begin
  1021. DownWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1022. UpWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1023. Wallarr[1,X,Z+1].Material.LibMaterialName:='Wall';
  1024. DownWallarr[1,X,Z+1].Visible:=false;
  1025. UpWallarr[1,X,Z+1].Visible:=false;
  1026. Wallarr[1,X,Z+1].Visible:=true;
  1027. end;
  1028. end else begin
  1029. if (Map[X+PosX-1,Z+PosZ].Inhalt.Sorte<>Integer(Green)) then begin
  1030. DownWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  1031. UpWallarr[0,X,Z].Material.LibMaterialName:='HalfWall';
  1032. Wallarr[0,X,Z].Material.LibMaterialName:='Wall';
  1033. end;
  1034. if (Map[X+PosX+1,Z+PosZ].Inhalt.Sorte<>Integer(Green)) then begin
  1035. DownWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  1036. UpWallarr[0,X+1,Z].Material.LibMaterialName:='HalfWall';
  1037. Wallarr[0,X+1,Z].Material.LibMaterialName:='Wall';
  1038. end;
  1039. if (Map[X+PosX,Z+PosZ].Inhalt.Sorte<>Integer(Green)) then begin
  1040. DownWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  1041. UpWallarr[1,X,Z].Material.LibMaterialName:='HalfWall';
  1042. Wallarr[1,X+1,Z].Material.LibMaterialName:='Wall';
  1043. end;
  1044. if (Map[X+PosX,Z+PosZ+1].Inhalt.Sorte<>Integer(Green)) then begin
  1045. DownWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1046. UpWallarr[1,X,Z+1].Material.LibMaterialName:='HalfWall';
  1047. Wallarr[1,X,Z+1].Material.LibMaterialName:='Wall';
  1048. end;
  1049. end;
  1050. end;
  1051. procedure TForm1.Creategoal;
  1052. var C1,C2,C3,C4:Integer;
  1053. begin
  1054. Lost:=false;
  1055. Won:=false;
  1056. if PGoal<>nil then begin
  1057. PGoal.Inhalt.Sorte:=0;
  1058. PGoal:=nil;
  1059. end;
  1060. Panel8.Visible:=false;
  1061. C1:=GoalPos.x;
  1062. C3:=GoalPos.y;
  1063. // Map[C1,C3].created:=true;
  1064. Map[C1,C3].Inhalt.Daten:=nil;
  1065. for C4:=C1-GoalProtectionRadius to C1+GoalProtectionRadius do
  1066. for C2:=C3-GoalProtectionRadius to C3+GoalProtectionRadius do begin
  1067. if sqrt(sqr(C1-C4)+sqr(C3-C2))<GoalProtectionRadius then begin
  1068. if not Map[C4,C2].created then CreateRaum(C4,C2);
  1069. if not Map[C4-1,C2].created then CreateRaum(C4,C2);
  1070. if not Map[C4,C2+1].created then CreateRaum(C4,C2);
  1071. if not Map[C4,C2-1].created then CreateRaum(C4,C2);
  1072. if not Map[C4+1,C2].created then CreateRaum(C4,C2);
  1073. if not GetRT(C4,C2).Passierbar then
  1074. Map[C4,C2].Inhalt.Sorte:=0;
  1075. Map[C4,C2].Walls:=[];
  1076. Map[C4+1,C2].Walls:=Map[C4+1,C2].Walls-[nx];
  1077. Map[C4,C2+1].Walls:=Map[C4,C2+1].Walls-[nz];
  1078. Map[C4,C2-1].Walls:=Map[C4,C2-1].Walls-[pz];
  1079. Map[C4-1,C2].Walls:=Map[C4-1,C2].Walls-[px];
  1080. Map[C4,C2].UpWalls:=[];
  1081. Map[C4+1,C2].UpWalls:=Map[C4+1,C2].UpWalls-[nx];
  1082. Map[C4,C2+1].UpWalls:=Map[C4,C2+1].UpWalls-[nz];
  1083. Map[C4,C2-1].UpWalls:=Map[C4,C2-1].UpWalls-[pz];
  1084. Map[C4-1,C2].UpWalls:=Map[C4-1,C2].UpWalls-[px];
  1085. Map[C4,C2].DownWalls:=[];
  1086. Map[C4+1,C2].DownWalls:=Map[C4+1,C2].DownWalls-[nx];
  1087. Map[C4,C2+1].DownWalls:=Map[C4,C2+1].DownWalls-[nz];
  1088. Map[C4,C2-1].DownWalls:=Map[C4,C2-1].DownWalls-[pz];
  1089. Map[C4-1,C2].DownWalls:=Map[C4-1,C2].DownWalls-[px];
  1090. end;
  1091. end;
  1092. Map[C1,C3].Inhalt.Sorte:=Integer(Goal);
  1093. PGoal:=@Map[C1,C3]; //todo 1: hier müssten "Daten" gefüllt werden
  1094. if GetRT(C1,C3).TurnRandom[Up]
  1095. or GetRT(C1,C3).TurnRandom[Down] then
  1096. Map[C1,C3].Inhalt.Daten:=@Richtungen[
  1097. TRichtung(Random(Integer(High(TRichtung))+1))];
  1098. ReloadRoom(C1,C3);
  1099. end;
  1100. procedure TForm1.FormCreate(Sender: TObject);
  1101. var C1,C3,C4:integer;
  1102. Repcount:Cardinal;
  1103. begin
  1104. Memo1.Align:=alClient;
  1105. Memo1.Width:=Form1.Width;
  1106. Memo1.Lines.Clear;
  1107. Memo1.Lines.Add('');
  1108. Memo1.Lines.Add('');
  1109. Memo1.Lines.Add('');
  1110. Memo1.Lines.Add('This is not a Bug and the Game has not stopped running.');
  1111. Memo1.Lines.Add('Please go to the next Room to remove this Message.');
  1112. Memo1.Lines.Add('This works at a proability of 20%.');
  1113. Memo1.Lines.Add('If you can see the Cursor you might be in a Menu.');
  1114. Memo1.Visible:=false;
  1115. ThrustBar.Position:=ThrustBar.Max;
  1116. LastPos:=ThrustBar.Position;
  1117. GLHUDText2.ModulateColor.SetColor(162,162,162);
  1118. GLHUDText2.Text:=GetCurrentVersion;
  1119. Randomize;
  1120. FrameCount:=0;
  1121. Camera:=GLCamera1;
  1122. Form2:=TForm2.Create(Self);
  1123. Form3:=TForm3.Create(Self);
  1124. Form4:=TForm4.Create(Self);
  1125. if colortest then
  1126. for C1:=0 to 20 do begin
  1127. npl:=NewPlayer(C1);
  1128. npl.Position.SetPoint(C1*3-30,2,0);
  1129. end;
  1130. MyID:=0;
  1131. if MyID>=Cardinal(Length(Players)) then setlength(Players,MyID+1);
  1132. if MyID>=Cardinal(Length(playerarr)) then begin
  1133. Setlength(playerarr,MyID+1);
  1134. for C3:=0 to High(playerarr) do
  1135. if not assigned(playerarr[C3]) then playerarr[C3]:=Form1.NewPlayer(C3);
  1136. end;
  1137. Players[MyID].Dead:=false;
  1138. Players[MyID].jumping:=false;
  1139. Players[MyID].X:=GLCamera1.Position.X;
  1140. Players[MyID].Y:=GLCamera1.Position.Y;
  1141. Players[MyID].Z:=GLCamera1.Position.Z;
  1142. Players[MyID].CeilWalk:=false;
  1143. ChangeSpeedTo(StartSpeed);
  1144. ini:=TMyIni.Create(ExtractFilePath(ParamStr(0))+'Settings.ini');
  1145. ROOMini:=TMyIni.Create(ExtractFilePath(ParamStr(0))+'Roomtypes.ini');
  1146. ROOMini.ReadFloatDefault:=0;
  1147. PanelIni:=TMyIni.Create(ExtractFilePath(ParamStr(0))+'PanelConfigs.ini');
  1148. if not ini.SectionExists('Difficulty') then begin
  1149. RewriteDifficulty;
  1150. end else ReadDifficulty;
  1151. if not ini.SectionExists('Multiplayer') then begin
  1152. RewriteMPSet;
  1153. end else ReadMPSet;
  1154. if (not ini.SectionExists('Roomtypelist'))
  1155. or (not FileExists(ExtractFilePath(ParamStr(0))+'Roomtypes.ini')) then
  1156. RewriteRoomtypes;
  1157. ReadRoomtypes;
  1158. if not FileExists(ExtractFilePath(ParamStr(0))+'PanelConfigs.ini')
  1159. then
  1160. RewritePanelConfigs;
  1161. ReadPanelConfigs;
  1162. Setlength(PlaneArr,Length(Roomtypes));
  1163. maxJumpHeight:=4-PlayerHeight[false];
  1164. Form2.loadTextures;
  1165. Form1.Icon.LoadFromFile('Wall.ico');
  1166. MainMenu.Visible:=true;
  1167. SettingsMenu.Visible:=false;
  1168. VideoMenu.Visible:=false;
  1169. MPMenu.Visible:=false;
  1170. MPHostMenu.Visible:=false;
  1171. MPJoinMenu.Visible:=false;
  1172. inMenu:=true;
  1173. if not inMenu then
  1174. GLUserInterface1.MouseLookActivate
  1175. else GLUserInterface1.MouseLookDeactivate;
  1176. GLHUDText1.ModulateColor.SetColor(0/255,168/255,255/255);
  1177. GLHUDText1.Visible:=true;
  1178. ChangeSpeedTo(StartSpeed);
  1179. GLHUDText1.Text:=
  1180. 'Speed: '+Floattostr(Round(100*Players[MyID].Speed)/100)+' m/s';
  1181. Panel13.Left:=Round(Self.Width*0.05);
  1182. Panel13.Width:=Round(Self.Width*0.9);
  1183. Panel13.Top:=Round(Self.Height*0.1);
  1184. Panel13.Height:=Round(Self.Height*0.8);
  1185. Panel13.Font.Size:=300;
  1186. PosX:=0;
  1187. PosZ:=0;
  1188. for C1:=-RaumRange to RaumRange+1 do
  1189. for C3:=-RaumRange to RaumRange+1 do begin
  1190. Wallarr[0,C1,C3]:=NewWall(20*C1-10,20*C3,1,20);
  1191. Wallarr[1,C1,C3]:=NewWall(20*C1,20*C3-10,20,1);
  1192. UpWallarr[0,C1,C3]:=NewUpWall(20*C1-10,20*C3,1,20);
  1193. UpWallarr[1,C1,C3]:=NewUpWall(20*C1,20*C3-10,20,1);
  1194. DownWallarr[0,C1,C3]:=NewDownWall(20*C1-10,20*C3,1,20);
  1195. DownWallarr[1,C1,C3]:=NewDownWall(20*C1,20*C3-10,20,1);
  1196. end;
  1197. for C1:=-RaumRange to RaumRange do
  1198. for C3:=-RaumRange to RaumRange do begin
  1199. PlaneArr[0,Down,C1,C3]:=NewPlane(C1,C3,Down,0);
  1200. PlaneArr[0,Up,C1,C3]:=NewPlane(C1,C3,Up,0);
  1201. end;
  1202. for C4:=1 to High(Roomtypes) do
  1203. for C1:=-RaumRange to RaumRange do
  1204. for C3:=-RaumRange to RaumRange do begin
  1205. if Roomtypes[C4].MaterialName[Down]=Roomtypes[0].MaterialName[Down]
  1206. then PlaneArr[C4,Down,C1,C3]:=PlaneArr[0,Down,C1,C3]
  1207. else PlaneArr[C4,Down,C1,C3]:=NewPlane(C1,C3,Down,C4);
  1208. if Roomtypes[C4].MaterialName[Up]=Roomtypes[0].MaterialName[Up]
  1209. then PlaneArr[C4,Up,C1,C3]:=PlaneArr[0,Up,C1,C3]
  1210. else PlaneArr[C4,Up,C1,C3]:=NewPlane(C1,C3,Up,C4);
  1211. end;
  1212. for C1:=-RaumRange to RaumRange do
  1213. for C3:=-RaumRange to RaumRange do begin
  1214. MuhNPCarr[C1,C3].Body:=NewMuhNPCBody(C1,C3);
  1215. MuhNPCarr[C1,C3].MoveX:=(Random-0.5)*3;
  1216. MuhNPCarr[C1,C3].MoveY:=(Random-0.5)*3;
  1217. MuhNPCarr[C1,C3].MoveZ:=(Random-0.5)*3;
  1218. end;
  1219. GLSceneViewer1.FieldOfView:=150;
  1220. GLSceneViewer1.Buffer.BackgroundColor:=RGB(66,66,66);
  1221. Panel11.Left:=Panel9.Left;
  1222. Panel11.Top:=Panel9.Top;
  1223. RichEdit1.Left:=Panel9.Left;
  1224. RichEdit1.Top:=Panel9.Top;
  1225. if not ini.SectionExists('Proportions') then RewriteOrigSizes
  1226. else ReadOrigSizes;
  1227. start:=GetTickCount;
  1228. Repcount:=0;
  1229. repeat
  1230. Inc(Repcount);
  1231. CreateMap;
  1232. InitValidate;
  1233. Validate(0,0,Down);
  1234. if Application.Terminated then Exit;
  1235. if GetTickCount>start+20000 then
  1236. if MessageDlg(
  1237. 'The game is taking very a long time to create a winable map. '+#13+#10+
  1238. 'Try using "reini.bat" to reset the settings. Continue trying?',
  1239. mtWarning, [mbYes, mbNo], 0) =mrNo then begin
  1240. Application.Terminate;
  1241. Break;
  1242. end else start:=High(Cardinal)-20000;
  1243. until valid[0,0,Down];
  1244. if showMapCreateTime then
  1245. MessageOut(
  1246. 'Map generated:'+#13+#10
  1247. +IntToStr(GetTickCount-start)+' ms,'+#13+#10
  1248. +IntToStr(Repcount)+' tries,'+#13+#10
  1249. +FloatToStr((GetTickCount-start)/repcount)+' ms/try',
  1250. 'Map generated') else InformationDump:=Repcount;
  1251. if Application.Terminated then Exit;
  1252. Reload;
  1253. SW:=TMyStopWatch.Create;
  1254. end;
  1255. procedure TForm1.CreateMap;
  1256. var C1,C3,C4,C5:Integer;
  1257. begin
  1258. for C1:=-mapsize to mapsize do
  1259. for C3:=-mapsize to mapsize do
  1260. Map[C1,C3].created:=false;
  1261. repeat
  1262. GoalPos.x:=RandomRange(-MaxGoalDist-1,MaxGoalDist+1);
  1263. GoalPos.y:=RandomRange(-MaxGoalDist-1,MaxGoalDist+1);
  1264. if Application.Terminated then Exit;
  1265. if GetTickCount>start+20000 then
  1266. if MessageDlg(
  1267. 'The game is taking very a long time to create a winable map. '+#13+#10+
  1268. 'Try using "reini.bat" to reset the settings. Continue trying?',
  1269. mtWarning, [mbYes, mbNo], 0) =mrNo then begin
  1270. Application.Terminate;
  1271. Break;
  1272. end else start:=High(Cardinal)-20000;
  1273. until (sqrt(sqr(GoalPos.X)+sqr(GoalPos.Y))>=MinGoalDist)
  1274. and (sqrt(sqr(GoalPos.X)+sqr(GoalPos.Y))<=MaxGoalDist);
  1275. PGoal:=nil;
  1276. Creategoal;
  1277. for C4:=-SpawnradiusNoWalls to SpawnradiusNoWalls do
  1278. for C5:=-SpawnradiusNoWalls to SpawnradiusNoWalls do begin
  1279. if sqrt(sqr(PosX-C4)+sqr(PosZ-C5))<SpawnradiusNoWalls then begin
  1280. if not Map[C4,C5].created then CreateRaum(C4,C5);
  1281. if not Map[C4-1,C5].created then CreateRaum(C4,C5);
  1282. if not Map[C4,C5+1].created then CreateRaum(C4,C5);
  1283. if not Map[C4,C5-1].created then CreateRaum(C4,C5);
  1284. if not Map[C4+1,C5].created then CreateRaum(C4,C5);
  1285. if not GetRT(C4,C5).Passierbar then
  1286. Map[C4,C5].Inhalt.Sorte:=0;
  1287. Map[C4,C5].Walls:=[];
  1288. Map[C4+1,C5].Walls:=Map[C4+1,C5].Walls-[nx];
  1289. Map[C4,C5+1].Walls:=Map[C4,C5+1].Walls-[nz];
  1290. Map[C4,C5-1].Walls:=Map[C4,C5-1].Walls-[pz];
  1291. Map[C4-1,C5].Walls:=Map[C4-1,C5].Walls-[px];
  1292. Map[C4,C5].UpWalls:=[];
  1293. Map[C4+1,C5].UpWalls:=Map[C4+1,C5].UpWalls-[nx];
  1294. Map[C4,C5+1].UpWalls:=Map[C4,C5+1].UpWalls-[nz];
  1295. Map[C4,C5-1].UpWalls:=Map[C4,C5-1].UpWalls-[pz];
  1296. Map[C4-1,C5].UpWalls:=Map[C4-1,C5].UpWalls-[px];
  1297. Map[C4,C5].DownWalls:=[];
  1298. Map[C4+1,C5].DownWalls:=Map[C4+1,C5].DownWalls-[nx];
  1299. Map[C4,C5+1].DownWalls:=Map[C4,C5+1].DownWalls-[nz];
  1300. Map[C4,C5-1].DownWalls:=Map[C4,C5-1].DownWalls-[pz];
  1301. Map[C4-1,C5].DownWalls:=Map[C4-1,C5].DownWalls-[px];
  1302. end;
  1303. end;
  1304. for C4:=-SpawnradiusNoSorte to SpawnradiusNoSorte do
  1305. for C5:=-SpawnradiusNoSorte to SpawnradiusNoSorte do
  1306. if sqrt(sqr(PosX-C4)+sqr(PosZ-C5))<SpawnradiusNoSorte then begin
  1307. if not Map[C4,C5].created then CreateRaum(C4,C5);
  1308. if GetRT(C4,C5).NotAtSpawn then
  1309. Map[C4,C5].Inhalt.Sorte:=0;
  1310. end;
  1311. end;
  1312. procedure TForm1.FormDestroy(Sender: TObject);
  1313. var C1,C2,C3:integer;
  1314. begin
  1315. if assigned(LastFrameCounts) then
  1316. FreeAndNil(LastFrameCounts);
  1317. Freeandnil(ini);
  1318. Freeandnil(ROOMini);
  1319. Timer1.Enabled:=false;
  1320. for C1:=-RaumRange to RaumRange do
  1321. for C2:=-RaumRange to RaumRange do begin
  1322. FreeAndNil(PlaneArr[0,Down,C1,C2]);
  1323. FreeAndNil(PlaneArr[0,Up,C1,C2]);
  1324. end;
  1325. for C1:=-RaumRange to RaumRange do
  1326. for C2:=-RaumRange to RaumRange do
  1327. for C3:=0 to High(Roomtypes) do begin
  1328. if Roomtypes[C3].MaterialName[Down]<>'Grass' then
  1329. if Assigned(PlaneArr[C3,Down,C1,C2]) then
  1330. FreeAndNil(PlaneArr[C3,Down,C1,C2]);
  1331. if Roomtypes[C3].MaterialName[Up]<>'Ceiling' then
  1332. if Assigned(PlaneArr[C3,Up,C1,C2]) then
  1333. FreeAndNil(PlaneArr[C3,Up,C1,C2]);
  1334. end;
  1335. end;
  1336. procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
  1337. var vis:Boolean; C2:Char;
  1338. begin
  1339. if Debug then
  1340. if Key='v' then begin
  1341. vis:=not Panel1.Visible;
  1342. Panel1.Visible:=vis;
  1343. Panel2.Visible:=vis;
  1344. Panel3.Visible:=vis;
  1345. Panel4.Visible:=vis;
  1346. Panel5.Visible:=vis;
  1347. Panel6.Visible:=vis;
  1348. end;
  1349. if Key='b' then begin
  1350. Close;
  1351. end;
  1352. if Key='m' then begin
  1353. if self.Left=OrigSizes[0] then begin
  1354. Self.BorderStyle:=bsnone;
  1355. Self.Left:=0;
  1356. Self.Top:=0;
  1357. Self.Width:=Screen.Width;
  1358. Self.Height:=Screen.Height;
  1359. end else begin
  1360. Self.BorderStyle:=TFormBorderStyle(Round(OrigSizes[4]));
  1361. Self.SetBounds(
  1362. Round(OrigSizes[0]),
  1363. Round(OrigSizes[1]),
  1364. Round(OrigSizes[2]),
  1365. Round(OrigSizes[3]));
  1366. end;
  1367. end;
  1368. if Key='n' then begin
  1369. ShellExecute(Handle, 'open','restart.bat',
  1370. PChar(extractFileName(application.ExeName)), nil, SW_SHOWNORMAL);
  1371. Close; //parameter dateiname
  1372. end;
  1373. if (Key='p') or (Key=Char(27)) then begin
  1374. inMenu:=not MainMenu.Visible;
  1375. MainMenu.Visible:=inMenu;
  1376. SettingsMenu.Visible:=false;
  1377. VideoMenu.Visible:=false;
  1378. MPMenu.Visible:=false;
  1379. MPHostMenu.Visible:=false;
  1380. MPJoinMenu.Visible:=false;
  1381. if not inMenu then begin
  1382. if players[MyId].CeilWalk then
  1383. GLCamera1.Up.SetVector(0,-1,0)
  1384. else
  1385. GLCamera1.Up.SetVector(0,1,0);
  1386. GLUserInterface1.MouseLookActivate;
  1387. end else GLUserInterface1.MouseLookDeactivate;
  1388. end;
  1389. if Key='-' then begin
  1390. inMenu:=not SettingsMenu.Visible;
  1391. MainMenu.Visible:=false;
  1392. SettingsMenu.Visible:=inMenu;
  1393. VideoMenu.Visible:=false;
  1394. MPMenu.Visible:=false;
  1395. MPHostMenu.Visible:=false;
  1396. MPJoinMenu.Visible:=false;
  1397. if not inMenu then begin
  1398. if players[MyId].CeilWalk then
  1399. GLCamera1.Up.SetVector(0,-1,0)
  1400. else
  1401. GLCamera1.Up.SetVector(0,1,0);
  1402. GLUserInterface1.MouseLookActivate;
  1403. end else GLUserInterface1.MouseLookDeactivate;
  1404. end;
  1405. if Key='w' then if inMenu then begin
  1406. MainMenu.SelectPrev;
  1407. SettingsMenu.SelectPrev;
  1408. VideoMenu.SelectPrev;
  1409. MPMenu.SelectPrev;
  1410. MPHostMenu.SelectPrev;
  1411. MPJoinMenu.SelectPrev;
  1412. end;
  1413. if Key='r' then begin
  1414. if (MessageDlg('Do you really want to respawn?', mtConfirmation,
  1415. [mbYes, mbNo], 0) = mrYes) then begin
  1416. Respawn;
  1417. while inMenu do begin
  1418. C2:='p';
  1419. FormKeyPress(Sender,C2);
  1420. end;
  1421. end;
  1422. end;
  1423. if Key='s' then if inMenu then begin
  1424. MainMenu.SelectNext;
  1425. SettingsMenu.SelectNext;
  1426. VideoMenu.SelectNext;
  1427. MPMenu.SelectNext;
  1428. MPHostMenu.SelectNext;
  1429. MPJoinMenu.SelectNext;
  1430. end;
  1431. if Key=Char(32) then begin
  1432. if not inMenu then begin
  1433. StartJump(MyID);
  1434. Form3.SendJump(MyID);
  1435. end else GLSceneViewer1MouseDown(Sender,TMouseButton(3),[],
  1436. Mouse.CursorPos.X,Mouse.CursorPos.Y);
  1437. jumppressed:=true;
  1438. end;
  1439. Panel5.Caption:=IntToStr(Ord(Key))+'='+Key;
  1440. end;
  1441. procedure TForm1.StartJump(ID:Integer);
  1442. begin
  1443. if jumppressed then Exit;
  1444. if Lost then Exit;
  1445. if players[ID].jumping then Exit;
  1446. players[ID].jumptime:=0.00001;
  1447. players[ID].jumping:=true;
  1448. end;
  1449. procedure TForm1.FormResize(Sender: TObject);
  1450. begin
  1451. RearrangePanels;
  1452. Camera.SetFieldOfView(160,GLSceneviewer1.Width);
  1453. end;
  1454. procedure TForm1.GLSceneViewer1MouseMove(Sender: TObject;
  1455. Shift: TShiftState; X, Y: Integer);
  1456. begin
  1457. if not inMenu then Exit;
  1458. if MainMenu.Visible then
  1459. MenuSelect2(MainMenu,X,Y);
  1460. if SettingsMenu.Visible then
  1461. MenuSelect2(SettingsMenu,X,Y);
  1462. if VideoMenu.Visible then
  1463. MenuSelect2(VideoMenu,X,Y);
  1464. if MPMenu.Visible then
  1465. MenuSelect2(MPMenu,X,Y);
  1466. if MPHostMenu.Visible then
  1467. MenuSelect2(MPHostMenu,X,Y);
  1468. if MPJoinMenu.Visible then
  1469. MenuSelect2(MPJoinMenu,X,Y);
  1470. if ThrustDrag then
  1471. ThrustBarMouseDown(Sender,TMousebutton(mbLeft),Shift,X,Y);
  1472. end;
  1473. procedure TForm1.Respawn;
  1474. var C3:Integer;
  1475. begin
  1476. if GameEnded then begin
  1477. MessageOut('Game has already ended. Try "N" instead.','Respawn impossible');
  1478. Exit;
  1479. end;
  1480. Lost:=false;
  1481. Panel8.Visible:=false;
  1482. Panel9.Visible:=false;
  1483. ThrustBar.Position:=ThrustBar.Max;
  1484. if Form3.ClientSocket.Active then begin
  1485. Form3.RequestNewID(Form3.ClientSocket.Socket);
  1486. end else begin
  1487. Players[MyID].Dead:=true;
  1488. MyID:=High(Players)+1;
  1489. Setlength(Players,MyID+1);
  1490. Setlength(playerarr,MyID+1);
  1491. for C3:=0 to High(playerarr) do
  1492. if not assigned(playerarr[C3]) then playerarr[C3]:=Form1.NewPlayer(C3);
  1493. Players[MyID].Dead:=false;
  1494. ChangeSpeedTo(StartSpeed);
  1495. Form1.GLHUDText1.Text:=
  1496. 'Speed: '+Floattostr(Round(100*Players[MyID].Speed)/100)+' m/s';
  1497. Form1.GLCamera1.Up.SetVector(0,1,0);
  1498. Form1.GLCamera1.Position.X:=0;
  1499. Form1.GLCamera1.Position.Z:=0;
  1500. Form1.GLNavigator1.VirtualUp.SetPoint(0,1,0);
  1501. PosX:=0;
  1502. PosZ:=0;
  1503. Players[MyID].jumping:=false;
  1504. Players[MyID].X:=0;
  1505. Players[MyID].Y:=0;
  1506. Players[MyID].Z:=0;
  1507. Players[MyID].jumptime:=0.00001;
  1508. Players[MyID].LastX:=0;
  1509. Players[MyID].LastZ:=0;
  1510. Players[MyID].Ceilwalk:=false;
  1511. Form3.SendCeilWalk;
  1512. Reload;
  1513. end;
  1514. end;
  1515. procedure TForm1.GLSceneViewer1MouseDown(Sender: TObject;
  1516. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1517. begin
  1518. if not inMenu then Exit;
  1519. MouseDownMenu(Sender,Button,Shift,X,Y);
  1520. end;
  1521. procedure TForm1.ThrustBarMouseDown(Sender: TObject; Button: TMouseButton;
  1522. Shift: TShiftState; X, Y: Integer);
  1523. var m,b:real;
  1524. begin
  1525. if not inMenu then Exit;
  1526. ThrustDrag:=true;
  1527. m:=-(ThrustBar.Max-ThrustBar.Min)/ThrustBar.Height;
  1528. b:=ThrustBar.Max-m*ThrustBar.Top;
  1529. ThrustBar.Position:=
  1530. Round(m*ScreenToClient(Mouse.CursorPos).Y+b);
  1531. if Round(m*Mouse.CursorPos.Y+b)>ThrustBar.Max then
  1532. ThrustBar.Position:=ThrustBar.Max
  1533. else if Round(m*Mouse.CursorPos.Y+b)<5 then
  1534. ThrustBar.Position:=5;
  1535. Form4.UpdateSpeed;
  1536. end;
  1537. procedure TForm1.GLSceneViewer1MouseUp(Sender: TObject;
  1538. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1539. begin
  1540. if not inMenu then Exit;
  1541. ThrustDrag:=false;
  1542. end;
  1543. end.