Subversion Repositories spacemission

Rev

Rev 1 | Rev 3 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit LevMain;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, MMSystem,
  7.   Dialogs, StdCtrls, ExtCtrls, Menus, DIB, DXClass, DXSprite, DXDraws,
  8.   DXSounds, Spin, ComCtrls;
  9.  
  10. type
  11.   TMainForm = class(TDXForm)
  12.     MainMenu: TMainMenu;
  13.     Spiel: TMenuItem;
  14.     Beenden: TMenuItem;
  15.     Hilfe: TMenuItem;
  16.     Mitarbeiter: TMenuItem;
  17.     Leer1: TMenuItem;
  18.     Level: TMenuItem;
  19.     Informationen: TMenuItem;
  20.     Leer2: TMenuItem;
  21.     Enemy1: TRadioButton;
  22.     Enemy2: TRadioButton;
  23.     Enemy3: TRadioButton;
  24.     Enemy4: TRadioButton;
  25.     Enemy5: TRadioButton;
  26.     Enemy6: TRadioButton;
  27.     Enemy7: TRadioButton;
  28.     ScrollBar: TScrollBar;
  29.     Bevel1: TBevel;
  30.     Bevel2: TBevel;
  31.     SelLabel: TLabel;
  32.     SelPanel: TPanel;
  33.     Bevel3: TBevel;
  34.     SLabel1a: TLabel;
  35.     SLabel2a: TLabel;
  36.     SLabel1b: TLabel;
  37.     SLabel2b: TLabel;
  38.     SLabel0: TLabel;
  39.     Neu: TMenuItem;
  40.     Image1: TImage;
  41.     SLabel3a: TLabel;
  42.     SLabel3b: TLabel;
  43.     SLabel4a: TLabel;
  44.     SLabel4b: TLabel;
  45.     LivesLabel: TLabel;
  46.     Quelltext1: TMenuItem;
  47.     StatusBar: TStatusBar;
  48.     N1: TMenuItem;
  49.     Spielfelderweitern1: TMenuItem;
  50.     LivesEdt: TEdit;
  51.     Lives: TUpDown;
  52.     procedure DXDrawFinalize(Sender: TObject);
  53.     procedure DXDrawInitialize(Sender: TObject);
  54.     procedure FormCreate(Sender: TObject);
  55.     procedure DXTimerTimer(Sender: TObject; LagCount: Integer);
  56.     procedure BeendenClick(Sender: TObject);
  57.     procedure FormDestroy(Sender: TObject);
  58.     procedure MitarbeiterClick(Sender: TObject);
  59.     procedure LevelClick(Sender: TObject);
  60.     procedure FormShow(Sender: TObject);
  61.     procedure InformationenClick(Sender: TObject);
  62.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  63.     procedure DXDrawMouseDown(Sender: TObject; Button: TMouseButton;
  64.       Shift: TShiftState; X, Y: Integer);
  65.     procedure EnemyClick(Sender: TObject);
  66.     procedure EnemyAdd(x, y, art, lives: integer);
  67.     procedure NeuClick(Sender: TObject);
  68.     procedure DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X,
  69.       Y: Integer);
  70.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  71.     procedure Quelltext1Click(Sender: TObject);
  72.     procedure Spielfelderweitern1Click(Sender: TObject);
  73.     procedure ScrollBarScroll(Sender: TObject; ScrollCode: TScrollCode;
  74.       var ScrollPos: Integer);
  75.     procedure LivesClick(Sender: TObject; Button: TUDBtnType);
  76.     procedure LivesEdtKeyPress(Sender: TObject; var Key: Char);
  77.     procedure LivesEdtChange(Sender: TObject);
  78.   public
  79.     { VCL-Ersatz }
  80.     spriteengine: tdxspriteengine;
  81.     dxtimer: tdxtimer;
  82.     imagelist: tdximagelist;
  83.     dxdraw: tdxdraw;
  84.     { Variablen }
  85.     FMenuItem: integer;
  86.     Enemys: TStrings;
  87.     ArtChecked: integer;
  88.     LiveEdit: integer;
  89.     ScrollP: integer;
  90.     AltScrollPos: integer;
  91.     Boss: boolean;
  92.     LevChanged: boolean;
  93.     NumEnemys: integer;
  94.     { Level-Routinen }
  95.     procedure EnemyCreate(x, y: integer);
  96.     procedure DestroyLevel;
  97.     procedure AnzeigeAct;
  98.     { Initialisiations-Routinen }
  99.     procedure DXInit;
  100.     procedure ProgramInit;
  101.     { Farb-Routinen }
  102.     function ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
  103.     procedure PalleteAnim(Col: TRGBQuad; Time: Integer);
  104.     { Sonstiges }
  105.     procedure LivesChange(newval: integer);
  106.   end;
  107.  
  108. var
  109.   MainForm: TMainForm;
  110.  
  111. implementation
  112.  
  113. uses
  114.   Global, LevSplash, LevSpeicherung, LevText, SplInfo, LevSource, LevOptions;
  115.  
  116. const
  117.   FileError = 'Die Datei kann von SpaceMission nicht geöffnet werden!';
  118.   status_info = ' Zeigen Sie mit dem Mauszeiger auf eine Einheit, um deren Eigenschaften anzuzeigen...';
  119.   status_lives = ' Leben: ';
  120.   status_nolives = ' Einheit hat keine Lebensangabe';
  121.   RasterW = 48;
  122.   RasterH = 32;
  123.  
  124. {$R *.DFM}
  125.  
  126. {$R WindowsXP.res}
  127.  
  128. type
  129.   TBackground = class(TBackgroundSprite)
  130.   protected
  131.     procedure DoMove(MoveCount: Integer); override;
  132.   end;
  133.  
  134.   TEnemy = class(TImageSprite)
  135.   private
  136.     Lives: integer;
  137.     Art: integer;
  138.     XCor: integer;
  139.     CorInit: boolean;
  140.   protected
  141.     procedure DoMove(MoveCount: Integer); override;
  142.   public
  143.     constructor Create(AParent: TSprite); override;
  144.   end;
  145.  
  146. procedure TMainForm.DXInit;
  147. begin
  148.   Imagelist.Items.LoadFromFile(FDirectory+'DirectX\Graphic.dxg');
  149.   ImageList.Items.MakeColorTable;
  150.   DXDraw.ColorTable := ImageList.Items.ColorTable;
  151.   DXDraw.DefColorTable := ImageList.Items.ColorTable;
  152.   DXDraw.UpdatePalette;
  153.   DXDraw.Initialize;
  154. end;
  155.  
  156. procedure TEnemy.DoMove(MoveCount: Integer);
  157. begin
  158.   if not CorInit then
  159.   begin
  160.     XCor := trunc(x) + (MainForm.ScrollP * RasterW);
  161.     CorInit := true;
  162.   end;
  163.   if MainForm.Enemys.IndexOf(floattostr(XCor)+'-'+floattostr(y)+':'+
  164.     inttostr(Art)+'('+inttostr(Lives)+')') = -1 then dead;
  165.   X := XCor - (MainForm.ScrollP * RasterW);
  166. end;
  167.  
  168. procedure TBackground.DoMove(MoveCount: Integer);
  169. begin
  170.   X := -(MainForm.ScrollP * RasterW);
  171. end;
  172.  
  173. constructor TEnemy.Create(AParent: TSprite);
  174. begin
  175.   inherited Create(AParent);
  176.   if MainForm.ArtChecked = 1 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker');
  177.   if MainForm.ArtChecked = 2 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker2');
  178.   if MainForm.ArtChecked = 3 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker3');
  179.   if MainForm.ArtChecked = 4 then Image := MainForm.ImageList.Items.Find('Enemy-Meteor');
  180.   if MainForm.ArtChecked = 5 then Image := MainForm.ImageList.Items.Find('Enemy-Disk');
  181.   if MainForm.ArtChecked = 6 then Image := MainForm.ImageList.Items.Find('Enemy-Disk2');
  182.   if MainForm.ArtChecked = 7 then Image := MainForm.ImageList.Items.Find('Enemy-Boss');
  183.   if MainForm.ArtChecked = 4 then Lives := 0 else Lives := MainForm.LiveEdit;
  184.   Art := MainForm.ArtChecked;
  185.   Width := Image.Width;
  186.   Height := Image.Height;
  187.   PixelCheck := True;
  188. end;
  189.  
  190. procedure TMainForm.FormCreate(Sender: TObject);
  191. var
  192.   Ergebnis: string;
  193.   daten: textfile;
  194.   ok: boolean;
  195. begin
  196.   { VCL-Ersatz start }
  197.   dxtimer := tdxtimer.create(self);
  198.   dxtimer.Interval := 100;
  199.   dxtimer.ActiveOnly := false;
  200.   dxtimer.Enabled := false;
  201.   dxtimer.OnTimer := DxTimerTimer;
  202.  
  203.   dxdraw := tdxdraw.Create(self);
  204.   dxdraw.Parent := self;
  205.   dxdraw.Left := 0;
  206.   dxdraw.Top := 0;
  207.   dxdraw.Width := 640;
  208.   dxdraw.Height := 480;
  209.   dxdraw.AutoInitialize := False;
  210.   dxdraw.AutoSize := False;
  211.   dxdraw.Color := clBlack;
  212.   dxdraw.Display.BitCount := 24;
  213.   dxdraw.Display.FixedBitCount := False;
  214.   dxdraw.Display.FixedRatio := False;
  215.   dxdraw.Display.FixedSize := False;
  216.   dxdraw.Display.Height := 600;
  217.   dxdraw.Display.Width := 800;
  218.   dxdraw.Options := [doAllowReboot, doWaitVBlank, doAllowPalette256, doCenter, doRetainedMode, doHardware, doSelectDriver];
  219.   dxdraw.OnFinalize := DXDrawFinalize;
  220.   dxdraw.OnInitialize := DXDrawInitialize;
  221.   dxdraw.ParentShowHint := False;
  222.   dxdraw.ShowHint := False;
  223.   dxdraw.TabOrder := 0;
  224.   dxdraw.OnMouseDown := DXDrawMouseDown;
  225.   dxdraw.OnMouseMove := DXDrawMouseMove;
  226.  
  227.   spriteengine := tdxspriteengine.create(self);
  228.   spriteengine.DXDraw := dxdraw;
  229.  
  230.   imagelist := tdximagelist.create(self);
  231.   imagelist.DXDraw := dxdraw;
  232.  
  233.   { VCL-Ersatz ende }
  234.  
  235.   ArtChecked := 1;
  236.   LiveEdit := 1;
  237.   // Leeres Level am Anfang braucht keine Beenden-Bestätigung.
  238.   // LevChanged := true;
  239.  
  240.   //Application.Title := 'SpaceMission '+ProgramVersion+' - Leveleditor';
  241.   Caption := 'SpaceMission '+ProgramVersion+' - Leveleditor';
  242.   DXInit;
  243.   if (paramcount > 0) and (fileexists(paramstr(1))) then
  244.   begin
  245.     AssignFile(daten, paramstr(1));
  246.     Reset(daten);
  247.     ok := true;
  248.     ReadLN(daten, Ergebnis);
  249.     if Ergebnis <> '; SpaceMission '+FCompVersion then ok := false;
  250.     ReadLN(daten, Ergebnis);
  251.     if ergebnis <> '; LEV-File' then ok := false;
  252.     if not ok then
  253.     begin
  254.       showmessage(FileError);
  255.       CloseFile(daten);
  256.       ProgramInit;
  257.       exit;
  258.     end;
  259.     { Laden }
  260.     CloseFile(daten);
  261.     exit;
  262.   end;
  263.   if fileexists(fdirectory+'Bilder\Auswahl.bmp') then
  264.     Image1.Picture.LoadFromFile(fdirectory+'Bilder\Auswahl.bmp');
  265.   {else
  266.     SelPanel.visible := false;}
  267.   ProgramInit;
  268. end;
  269.  
  270. procedure TMainForm.FormDestroy(Sender: TObject);
  271. begin
  272.   Enemys.Free;
  273.   //spriteengine.Free;
  274.   dxtimer.Free;
  275.   imagelist.Free;
  276.   dxdraw.free;
  277. end;
  278.  
  279. procedure TMainForm.BeendenClick(Sender: TObject);
  280. begin
  281.   close;
  282. end;
  283.  
  284. procedure TMainForm.DXDrawInitialize(Sender: TObject);
  285. begin
  286.   DXTimer.Enabled := True;
  287. end;
  288.  
  289. procedure TMainForm.DXDrawFinalize(Sender: TObject);
  290. begin
  291.   DXTimer.Enabled := False;
  292. end;
  293.  
  294. procedure TMainForm.DXTimerTimer(Sender: TObject; LagCount: Integer);
  295. begin
  296.   if not DXDraw.CanDraw then exit;
  297.   LagCount := 1000 div 60;
  298.   SpriteEngine.Move(LagCount);
  299.   SpriteEngine.Dead;
  300.   DxDraw.Surface.Fill(0);
  301.   SpriteEngine.Draw;
  302.   DXDraw.Flip;
  303. end;
  304.  
  305. function TMainForm.ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
  306. begin
  307.   with Result do
  308.   begin
  309.     rgbRed := Src.rgbRed+((Dest.rgbRed-Src.rgbRed)*Percent div 256);
  310.     rgbGreen := Src.rgbGreen+((Dest.rgbGreen-Src.rgbGreen)*Percent div 256);
  311.     rgbBlue := Src.rgbBlue+((Dest.rgbBlue-Src.rgbBlue)*Percent div 256);
  312.     rgbReserved := 0;
  313.   end;
  314. end;
  315.  
  316. procedure TMainForm.PalleteAnim(Col: TRGBQuad; Time: Integer);
  317. var
  318.   i: Integer;
  319.   t, t2: DWORD;
  320.   ChangePalette: Boolean;
  321.   c: Integer;
  322. begin
  323.   if DXDraw.Initialized then
  324.   begin
  325.     c := DXDraw.Surface.ColorMatch(RGB(Col.rgbRed, Col.rgbGreen, Col.rgbBlue));
  326.     ChangePalette := False;
  327.     if DXDraw.CanPaletteAnimation then
  328.     begin
  329.       t := GetTickCount;
  330.       while Abs(GetTickCount-t)<Time do
  331.       begin
  332.         t2 := Trunc(Abs(GetTickCount-t)/Time*255);
  333.         for i := 0 to 255 do
  334.           DXDraw.ColorTable[i] := ComposeColor(Col, DXDraw.DefColorTable[i], t2);
  335.         DXDraw.UpdatePalette;
  336.         ChangePalette := True;
  337.       end;
  338.     end else
  339.       Sleep(Time);
  340.     for i := 0 to 4 do
  341.     begin
  342.       DXDraw.Surface.Fill(c);
  343.       DXDraw.Flip;
  344.     end;
  345.     if ChangePalette then
  346.     begin
  347.       DXDraw.ColorTable := DXDraw.DefColorTable;
  348.       DXDraw.UpdatePalette;
  349.     end;
  350.     DXDraw.Surface.Fill(c);
  351.     DXDraw.Flip;
  352.   end;
  353. end;
  354.  
  355. procedure TMainForm.ProgramInit;
  356. {var
  357.   i, j: Integer;}
  358. begin
  359.   Enemys := TStringList.create;
  360.   sleep(500);
  361.   //PlayerSprite
  362.   with TBackground.Create(SpriteEngine.Engine) do
  363.   begin
  364.     SetMapSize(1, 1);
  365.     Image := mainform.ImageList.Items.Find('Star3');
  366.     Z := -13;
  367.     Y := 40;
  368.     Tile := True;
  369.   end;
  370.   with TBackground.Create(SpriteEngine.Engine) do
  371.   begin
  372.     SetMapSize(1, 1);
  373.     Image := mainform.ImageList.Items.Find('Star2');
  374.     Z := -12;
  375.     Y := 30;
  376.     Tile := True;
  377.   end;
  378.   with TBackground.Create(SpriteEngine.Engine) do
  379.   begin
  380.     SetMapSize(1, 1);
  381.     Image := mainform.ImageList.Items.Find('Star1');
  382.     Z := -11;
  383.     Y := 10;
  384.     Tile := True;
  385.   end;
  386.   with TBackground.Create(SpriteEngine.Engine) do
  387.   begin
  388.     SetMapSize(1, 1);
  389.     Image := mainform.ImageList.Items.Find('Matrix');
  390.     Z := -10;
  391.     Tile := True;
  392.   end;
  393.   {with TBackground.Create(SpriteEngine.Engine) do
  394.   begin
  395.     SetMapSize(200, 10);
  396.     Y := 10;
  397.     Z := -13;
  398.     FSpeed := 1 / 2;
  399.     Tile := True;
  400.     for i := 0 to MapHeight-1 do
  401.     begin
  402.       for j := 0 to MapWidth-1 do
  403.       begin
  404.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 8);
  405.         if Random(100)<95 then Chips[j, i] := -1;
  406.       end;
  407.     end;
  408.   end;
  409.   with TBackground.Create(SpriteEngine.Engine) do
  410.   begin
  411.     SetMapSize(200, 10);
  412.     Y := 30;
  413.     Z := -12;
  414.     FSpeed := 1;
  415.     Tile := True;
  416.     for i := 0 to MapHeight-1 do
  417.     begin
  418.       for j := 0 to MapWidth-1 do
  419.       begin
  420.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 4);
  421.         if Random(100)<95 then Chips[j, i] := -1;
  422.       end;
  423.     end;
  424.   end;
  425.   with TBackground.Create(SpriteEngine.Engine) do
  426.   begin
  427.     SetMapSize(200, 10);
  428.     Y := 40;
  429.     Z := -11;
  430.     FSpeed := 2;
  431.     Tile := True;
  432.     for i := 0 to MapHeight-1 do
  433.     begin
  434.       for j := 0 to MapWidth-1 do
  435.       begin
  436.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 2);
  437.         if Random(100)<95 then Chips[j, i] := -1;
  438.       end;
  439.     end;
  440.   end;}
  441.   PalleteAnim(RGBQuad(0, 0, 0), 300);
  442.   mainform.Visible := true;
  443. end;
  444.  
  445. procedure TMainForm.MitarbeiterClick(Sender: TObject);
  446. begin
  447.   if not fileexists(fdirectory+'Texte\Mitwirkende.txt') then
  448.   begin
  449.     MessageDLG('Die Datei "Texte\Mitwirkende.txt" ist nicht mehr vorhanden. Die Aktion wird abgebrochen!',
  450.       mtWarning, [mbOK], 0);
  451.   end
  452.   else
  453.   begin
  454.     TextForm.memo1.lines.loadfromfile(FDirectory+'Texte\Mitwirkende.txt');
  455.     TextForm.showmodal;
  456.   end;
  457. end;
  458.  
  459. procedure TMainForm.LevelClick(Sender: TObject);
  460. begin
  461.   speicherungform.showmodal;
  462. end;
  463.  
  464. procedure TMainForm.FormShow(Sender: TObject);
  465. begin
  466.   SplashForm.Hide;
  467.   SplashForm.Free;
  468.  
  469.   dxtimer.Enabled := true;
  470.   dxtimer.ActiveOnly := true;
  471. end;
  472.  
  473. procedure TMainForm.InformationenClick(Sender: TObject);
  474. begin
  475.   InfoForm.showmodal;
  476. end;
  477.  
  478. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  479. begin
  480.   SpriteEngine.Engine.Clear;
  481.   DXTimer.Enabled := False;
  482. end;
  483.  
  484. procedure TMainForm.DXDrawMouseDown(Sender: TObject; Button: TMouseButton;
  485.   Shift: TShiftState; X, Y: Integer);
  486. var
  487.   i, j, k, l, ex, ey: integer;
  488.   ok, breaked: boolean;
  489. begin
  490.   ex := trunc(x/RasterW) * RasterW;
  491.   ey := trunc(y/RasterH) * RasterH;
  492.   EnemyCreate(ex, ey);
  493.   breaked := false;
  494.   { Setzen }
  495.   if Button = mbLeft then
  496.   begin
  497.     ok := true;
  498.     if (ArtChecked = 7) and boss then ok := false
  499.     else
  500.     begin
  501.       for i := 1 to 7 do
  502.       begin
  503.         for j := 0 to 999 do
  504.         begin
  505.           if boss then
  506.           begin
  507.             for k := 0 to 3 do
  508.             begin
  509.               for l := 0 to 1 do
  510.               begin
  511.                 if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':7('+inttostr(j)+')') <> -1 then
  512.                 begin
  513.                   ok := false;
  514.                   break;
  515.                 end;
  516.               end;
  517.               if not ok then break;
  518.             end;
  519.             if not ok then break;
  520.           end;
  521.           if Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
  522.             inttostr(i)+'('+inttostr(j)+')') <> -1 then
  523.           begin
  524.             ok := false;
  525.             break;
  526.           end;
  527.         end;
  528.         if not ok then break;
  529.       end;
  530.     end;
  531.     if ok then
  532.     begin
  533.       if ArtChecked <> 4 then
  534.         Enemys.Add(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
  535.           inttostr(ArtChecked)+'('+inttostr(LiveEdit)+')')
  536.       else
  537.         Enemys.Add(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
  538.           inttostr(ArtChecked)+'(0)');
  539.       inc(NumEnemys);
  540.       if ArtChecked = 7 then boss := true;
  541.     end
  542.     else beep;
  543.   end
  544.   { Löschen }
  545.   else if Button = mbRight then
  546.   begin
  547.     for i := 1 to 7 do
  548.     begin
  549.       for j := 0 to 999 do
  550.       begin
  551.         if boss and (i = 7) then
  552.         begin
  553.           for k := 0 to 3 do
  554.           begin
  555.             for l := 0 to 1 do
  556.             begin
  557.               if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')') <> -1 then
  558.               begin
  559.                 Enemys.Delete(Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')'));
  560.                 Boss := false;
  561.                 dec(NumEnemys);
  562.                 breaked := true;
  563.                 break;
  564.               end;
  565.             end;
  566.             if breaked then break;
  567.           end;
  568.         end;
  569.         if Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
  570.           inttostr(i)+'('+inttostr(j)+')') <> -1 then
  571.         begin
  572.           Enemys.Delete(Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+
  573.             ':'+inttostr(i)+'('+inttostr(j)+')'));
  574.           if i = 7 then Boss := false;
  575.           dec(NumEnemys);
  576.           breaked := true;
  577.           break;
  578.         end;
  579.       end;
  580.       if breaked then break;
  581.     end;
  582.   end;
  583.   LevChanged := true;
  584.   AnzeigeAct;
  585. end;
  586.  
  587. procedure TMainForm.EnemyClick(Sender: TObject);
  588. begin
  589.   if sender = Enemy1 then ArtChecked := 1;
  590.   if sender = Enemy2 then ArtChecked := 2;
  591.   if sender = Enemy3 then ArtChecked := 3;
  592.   if sender = Enemy4 then ArtChecked := 4;
  593.   if sender = Enemy5 then ArtChecked := 5;
  594.   if sender = Enemy6 then ArtChecked := 6;
  595.   if sender = Enemy7 then ArtChecked := 7;
  596.   Image1.Left := -(87 * (ArtChecked - 1)) + 1;
  597.   Lives.Enabled := sender <> Enemy4;
  598.   LivesLabel.Enabled := sender <> Enemy4;
  599.   if sender = Enemy4 then LivesEdt.Font.Color := clBtnShadow // andere farbe?
  600.     else LivesEdt.Font.Color := clWindowText;
  601. end;
  602.  
  603. procedure TMainForm.EnemyCreate(x, y: integer);
  604. var
  605.   Enemy: TSprite;
  606. begin
  607.   Enemy := TEnemy.Create(SpriteEngine.Engine);
  608.   Enemy.x := x;
  609.   Enemy.y := y;
  610. end;
  611.  
  612. procedure TMainForm.DestroyLevel;
  613. begin
  614.   ScrollBar.Position := 0;
  615.   Enemys.Clear;
  616.   NumEnemys := 0;
  617.   Boss := false;
  618.   LevChanged := true;
  619.   Lives.Position := 1;
  620.   LivesChange(Lives.Position);
  621.   Enemy1.Checked := true;
  622.   EnemyClick(Enemy1);
  623.   AnzeigeAct;
  624. end;
  625.  
  626. procedure TMainForm.AnzeigeAct;
  627. begin
  628.   SLabel1b.Caption := inttostr(NumEnemys);
  629.   if Boss then SLabel2b.Caption := 'Ja' else SLabel2b.Caption := 'Nein';
  630.   SLabel3b.Caption := inttostr(ScrollBar.Max);
  631.   if LevChanged then
  632.   begin
  633.     SLabel4a.Font.Color := $00000096;
  634.     SLabel4b.Font.Color := $00000096;
  635.     SLabel4b.Caption := 'Nein';
  636.   end
  637.   else
  638.   begin
  639.     SLabel4a.Font.Color := $00009600;
  640.     SLabel4b.Font.Color := $00009600;
  641.     SLabel4b.Caption := 'Ja';
  642.   end;
  643. end;
  644.  
  645. procedure TMainForm.EnemyAdd(x, y, art, lives: integer);
  646. begin
  647.   Enemys.Add(inttostr(x)+'-'+inttostr(y)+':'+inttostr(art)+'('+inttostr(lives)+')');
  648. end;
  649.  
  650. procedure TMainForm.NeuClick(Sender: TObject);
  651. begin
  652.   if MessageDlg('Level wirklich löschen?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  653.     DestroyLevel;
  654. end;
  655.  
  656. procedure TMainForm.DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X,
  657.   Y: Integer);
  658. var
  659.   ex, ey, i, j, k, l, wert: integer;
  660.   breaked: boolean;
  661. begin
  662.   if sender <> DxDraw then
  663.   begin
  664.     StatusBar.SimpleText := status_info;
  665.     exit;
  666.   end;
  667.   ex := trunc(x/RasterW) * RasterW;
  668.   ey := trunc(y/RasterH) * RasterH;
  669.   wert := -1;
  670.   breaked := false;
  671.   for i := 1 to 7 do
  672.   begin
  673.     for j := 0 to 999 do
  674.     begin
  675.       if boss and (i = 7) then
  676.       begin
  677.         for k := 0 to 3 do
  678.         begin
  679.           for l := 0 to 1 do
  680.           begin
  681.             if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')') <> -1 then
  682.             begin
  683.               wert := j;
  684.               breaked := true;
  685.               break;
  686.             end;
  687.           end;
  688.           if breaked then break;
  689.         end;
  690.       end;
  691.       if (breaked = false) and (Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
  692.         inttostr(i)+'('+inttostr(j)+')') <> -1) then
  693.       begin
  694.         wert := j;
  695.         breaked := true;
  696.         break;
  697.       end;
  698.     end;
  699.     if breaked then break;
  700.   end;
  701.   if wert <> -1 then
  702.   begin
  703.     if wert > 0 then
  704.       StatusBar.SimpleText := status_lives + inttostr(wert)
  705.     else
  706.       StatusBar.SimpleText := status_nolives;
  707.   end
  708.   else
  709.     StatusBar.SimpleText := status_info;
  710. end;
  711.  
  712. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  713. begin
  714.   if LevChanged then
  715.     CanClose := MessageDlg('Beenden ohne abspeichern?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
  716. end;
  717.  
  718. procedure TMainForm.Quelltext1Click(Sender: TObject);
  719. begin
  720.   SourceForm.Aktualisieren;
  721.   SourceForm.showmodal;
  722. end;
  723.  
  724. procedure TMainForm.Spielfelderweitern1Click(Sender: TObject);
  725. begin
  726.   LevelForm.Aktualisieren;
  727.   LevelForm.showmodal;
  728. end;
  729.  
  730. procedure TMainForm.ScrollBarScroll(Sender: TObject;
  731.   ScrollCode: TScrollCode; var ScrollPos: Integer);
  732. begin
  733.   ScrollP := ScrollPos;
  734. end;
  735.  
  736. procedure TMainForm.LivesChange(newval: integer);
  737. begin
  738.   LiveEdit := newval;
  739.   livesedt.Text := inttostr(LiveEdit);
  740.   lives.Position := newval;
  741. end;
  742.  
  743. procedure TMainForm.LivesClick(Sender: TObject; Button: TUDBtnType);
  744. begin
  745.   LivesChange(lives.Position);
  746. end;
  747.  
  748. procedure TMainForm.LivesEdtKeyPress(Sender: TObject; var Key: Char);
  749. begin
  750.   if not (Key in [#13, #08, '0'..'9']) then
  751.     Key := #0;
  752. end;
  753.  
  754. procedure TMainForm.LivesEdtChange(Sender: TObject);
  755. begin
  756.   LivesChange(strtoint(livesedt.text));
  757. end;
  758.  
  759. end.
  760.  
  761.